9.1 — What is Node, really?
Way back in 0.2 you learned that your JavaScript runs inside an engine called V8, bolted inside a browser. Here’s the twist that created half the modern software world: in 2009, Node.js unbolted that engine and ran it directly on the computer — no browser around it. Same engine. Same language. Completely different powers.
This matters to you personally: Playwright is a Node program. The next two phases live in this world — time to meet it properly.
// hello.js — a plain file on YOUR computer
console.log("hello from my computer");
// the terminal:
// $ node hello.js
// hello from my computer
// browser things, asked in Node:
console.log(typeof document);
console.log(typeof window);
// Node-only powers (this phase):
// files · folders · env vars · networkRecall the 0.2 picture: your code always ran inside an ENGINE — V8 — which itself sat inside a browser, next to the DOM, the tabs, the window. The engine never needed the browser; it was just built into one.
The deeper story, with the real names for things — this part is what turns “I saw it” into “I can explain it.”
Precision on the name: Node isn’t “JavaScript on the server” so much as a JavaScript runtime — a C++ program embedding V8 and wiring it to the operating system. Servers became its most famous job, but scripts, build tools, and test runners are equally native citizens.
The globals really are different: in the browser the global object is window; in Node it’s called globalThis (with an older alias, global). Some names exist in both worlds — console, setTimeout, fetch — because both runtimes chose to provide them, not because they come with the language.
Version note: Node releases in even-numbered LTS lines (“long-term support”) — the ones real teams run. When 9.8 has you install Node, LTS is the button you’ll press.
Job note: when a Playwright suite runs in CI, there is often no browser window at all — Node runs your test code and drives headless browsers. Understanding “my code lives in Node, the page lives in the browser” will explain a dozen Phase-11 mysteries before they happen (why you can’t just touch document from a test, for one).
⌨️ compare the two toolbelts
The two runtimes share a language but carry different gifts. Given both toolbelts, compute what they share and what only the browser has — with array tools, not eyeballs.
requirements:
- Create
browserGiftsas["document", "window", "fetch"]andnodeGiftsas["fs", "process", "fetch"]. - Print every gift they SHARE — filter one list down to entries the other list includes (4.9’s gate + a method that answers “is this in there?”).
- Then print each browser-ONLY gift, one per line, in order — same tools, opposite test.
when you press RUN, the console must show exactly:
✏️ Quick check 1
In Node, what does console.log(typeof document) print?
✏️ Quick check 2
Do closures, promises, and async/await behave differently in Node than in the browser? Type yes or no.
✏️ Quick check 3
What do you type in the terminal to run a file called report.js with Node?
🗣️ Now teach it back
Explain to a friend what Node.js actually is — same engine, different shell — including what disappears compared to the browser, what appears instead, and why Playwright cares.
Write it as if your friend is sitting next to you. Saved to your journal — future-you will use these notes to teach others.