Hiprup

What is the difference between Node.js and browser-side JavaScript?

Both run JavaScript on the V8 engine, but they operate in completely different environments with different APIs and purposes.

1. Environment

  • Browser — runs in a sandboxed browser tab, for client-side UI.

  • Node.js — runs on the server or local machine, for backend and system-level tasks.

2. Global object

  • Browserwindow (and document, navigator).

  • Node.jsglobal (and process, Buffer).

3. APIs available

  • Browser — DOM, fetch, localStorage, alert, Web APIs.

  • Node.jsfs, http, crypto, os, child_process, stream — no DOM.

4. Module system

  • Browser — ES Modules (import/export) natively.

  • Node.js — supports both CommonJS (require) and ES Modules.

5. Security model

  1. Browser — sandboxed, restricted (same-origin policy, no file system access).

  2. Node.js — full access to the OS, filesystem, and network.

Structure your answer around three axes: available APIs (DOM vs file system), security model (sandboxed vs full system access), and module systems. This shows a systematic understanding.

What is the difference between Node.js and browser-side JavaScript? | Hiprup