🟢 Node.js
Beginner
What is the difference between Node.js and the browser JavaScript environment?
Answer
Both Node.js and the browser run JavaScript using the V8 engine, but they operate in fundamentally different environments. The browser provides APIs for DOM manipulation (document, window), browser storage (localStorage, cookies), Web APIs (fetch, WebSockets), and user interaction events. Node.js has no DOM — instead it provides APIs for the operating system: fs (file system), http (networking), path, os, child_process, and more. Node.js uses CommonJS modules (require()) and now supports ES Modules; browsers primarily use ES Modules (import/export). Node.js has access to the local file system; browsers do not (for security). Global objects also differ: browser has window, Node.js has global (now globalThis in both).