Globals, fetch availability, file/network APIs
Detect runtime safely (globalThis/window/global), check fetch availability, and understand why files need Node while browser focuses on DOM/network.
Big picture
Goal: Know where your code runs.
- Globals: globalThis, window, global
- fetch: feature-detect, not assume
- Files: Node has fs; browsers do not
- URLs: URL works in both

Runtime sniff (safe)
Use typeof checks to avoid ReferenceErrors and learn where you are running.
// Detect presence of common globals
const hasWindow = typeof window !== "undefined";
const hasGlobal = typeof global !== "undefined";
const hasProcess = typeof process !== "undefined" && process && typeof process.version === "string";
console.log("globalThis exists?", typeof globalThis !== "undefined");
console.log("window?", hasWindow);
console.log("global?", hasGlobal);
console.log("Node process?", hasProcess);

All lessons in this course
- Globals, fetch availability, file/network APIs
- ESM loader quirks, path/URL differences
- Env variables & config patterns