nodejs Interview Questions

Beginner Level13 questions
JS runtime on V8 engine — single-threaded, event-driven, non-blocking I/O.
Minimal Node.js web framework for routing, middleware, and APIs.
Mechanism that processes async callbacks — timers → poll → check → close.
HTTP-based APIs using GET/POST/PUT/DELETE for stateless CRUD operations.
Always-on computers serving web content — no screen, optimized for network I/O.
Browser security blocking cross-origin requests — fix with ACAO headers.
Fast V8, non-blocking I/O, JS everywhere, huge npm ecosystem, great for real-time.
Single-threaded JS execution + multi-threaded libuv for heavy I/O behind the scenes.
Event loop + non-blocking I/O + libuv thread pool — delegates async work, processes callbacks.
GET=read, POST=create, PUT=replace, PATCH=partial update, DELETE=remove.
Project manifest — metadata, dependencies, scripts, and configuration.
Locks exact dependency versions for consistent installs across teams.
dependencies = production packages; devDependencies = dev-only tools (testing, linting).
Intermediate Level10 questions
Functions in the req-res cycle — next() passes control to the next middleware.
fs module — readFile/writeFile (async) or readFileSync/writeFileSync (sync).
Header.Payload.Signature — self-contained token for stateless authentication.
Login → verify password → create JWT → client sends JWT → server extracts userId.
Stateless auth for stateless HTTP — expiresIn sets auto-expiry time.
Full-duplex, persistent TCP connection for real-time bidirectional data flow.
Tells Git which files to ignore — node_modules, .env, build output.
Primary key = unique row identifier; Foreign key = reference to another table's primary key.
Process data in chunks — Readable, Writable, Duplex, Transform.
Fixed-size raw binary data storage — used for streams, files, and network I/O.
Advanced Level13 questions
constructor() initializes instances; super() calls parent's constructor.
Syntactic sugar over prototypes — clean syntax for object creation and inheritance.
Automatic memory cleanup — unreachable objects are freed via mark-and-sweep.
No real destructors in JS — FinalizationRegistry runs cleanup after GC (unreliable timing).
Abstraction = hide complexity; Encapsulation = bundle data + restrict access.
Fork workers per CPU core — master distributes connections via round-robin.
spawn() = run any command with streams; fork() = new Node.js process with IPC messaging.
Built-in module functions — fs, http, path, os, crypto for server-side ops.
Creates child Node.js process with IPC channel for message passing.
Reactor = wait for I/O readiness then handle (Node.js); Proactor = async I/O with completion callback.
Tells app its environment — controls logging, errors, caching, and optimization.
r=read, w=write(truncate), a=append, r+=read+write, w+=read+write(truncate), ax=create new only.
0=success, 1=uncaught exception, 3=parse error, 5=V8 fatal, 9=invalid arg.