Skip to content
Learn Netverks

Lesson

Step 3/36 8% through track

nodejs-vs-browser-js

Node.js vs browser JavaScript

Last reviewed May 28, 2026 Content v20260528
Track mode
nodejs_server
Means
Node sandbox
Reading
~2 min
Level
beginner

This lesson

This lesson teaches Node.js vs browser JavaScript: the syntax, APIs, and habits you need before advancing in Node.js.

Teams ship Node.js vs browser JavaScript on every Node.js codebase—skipping it leaves gaps in debugging and code reviews.

You will apply Node.js vs browser JavaScript in contexts like: REST/GraphQL APIs, BFF layers, CLIs, webhooks, and real-time services (with WebSockets).

Run JavaScript on the Node runner when configured—never mix arbitrary shell commands in lessons.

At the start of the track—complete before lessons that assume you understand the server playground.

JavaScript is one language with two major runtimes. Syntax overlaps (functions, classes, async/await), but globals, APIs, and security boundaries differ sharply.

Browser-only

  • document, window, DOM APIs, fetch (also in modern Node)
  • Sandboxed—no raw file system or arbitrary shell (without extensions)
  • User-controlled environment—never trust client code for secrets

Node-only

  • process, __dirname (CommonJS), import.meta.url (ESM)
  • node:fs, node:http, node:path, node:crypto
  • Full server privileges—validate input, guard file paths, manage secrets via env vars

Shared

Modern ECMAScript features—const/let, arrow functions, classes, modules, promises, Map/Set—work in both when supported by the runtime version. Always check Node LTS release notes for feature support.

Important interview questions and answers

  1. Q: Can you use document in Node?
    A: No—there is no DOM. Use templates on the server (EJS, React SSR) or return JSON for SPAs.
  2. Q: Is fetch available in Node?
    A: Yes in modern Node (18+ globally)—earlier versions needed node-fetch or http.
  3. Q: Why share JS on client and server?
    A: One language for full-stack teams, shared validation schemas (e.g. Zod), and less context switching—trade-off is coupling if not modularized.

Self-check

  1. Name two globals available in Node but not in the browser.
  2. Why must secrets live on the server only?

Interview prep

window vs global in Node?

Browser JS has window and DOM APIs; Node has globalThis, process, and built-in modules like fs and http—no document or localStorage.

Interview tip Lesson completion confidence

Can you explain this lesson in 30 seconds without reading notes?

Not saved yet.

Playground

Runs on the configured server runner (dev: npm run runner with LEARNING_RUNNER_ENABLED=true). Output appears below the editor.

Check yourself

Multiple choice — immediate feedback.

Discussion

Past discussion is visible to everyone. Only logged-in users can post comments and replies.

Starter discussion topics

  • window missing impact?
  • DOM API in Node?

Sign up or log in to post comments and sync lesson progress across devices.

No discussion yet. Be the first to ask a question.

Jump