What is Node.js and how does it differ from browser JavaScript
V8 engine, libuv, runtime vs browser, global object, process object, single-threaded model
Node.js Is Not a Language
Node.js is a runtime environment that executes JavaScript outside the browser. It bundles the V8 engine (the same one Chrome uses) with libuv, a C library that provides the event loop, async I/O, and a thread pool.
Browser JS has window, document, and DOM APIs. Node.js replaces those with process, __dirname, and system-level modules like fs and net. The language is identical; the available globals are not.
The process Object
The process global gives you runtime information and control:
console.log(process.version); // Node.js version e.g. v20.11.0
console.log(process.platform); // linux darwin win32
console.log(process.argv); // CLI args array
console.log(process.env.NODE_ENV); // environment variable
process.exit(1); // exit with error codeSingle Thread, Not Single Task
Node.js runs JavaScript on one thread. That does not mean it handles one thing at a time. Blocking operations like file reads are handed off to libuv's thread pool or the OS kernel. When they complete, a callback is queued back to the JS thread. This is why CPU-heavy synchronous work blocks everything, but waiting for a network response does not. Key mental model: one JS thread, many concurrent I/O operations.
