Skip to content
tezvyn:

Node.js & Express

Node.js, Express, Fastify, NestJS, Bun, Deno

65 bites

Test yourself: Top 30 intermediate Node.js & Express interview questionsMultiple choice, with the correct answer and why it is correct on every question. Free, no sign-in.

Intermediate interview questions in Node.js & Express

intermediate1 min read

Order of the Node.js event loop phases

Timers, pending callbacks, poll, check, close phases in order; I/O completion runs in poll.

intermediate1 min read

nextTick vs setImmediate vs setTimeout(fn, 0)

NextTick is a microtask that drains before the loop continues; setImmediate runs in check; setTimeout(0) in timers.

intermediate1 min read

Offloading CPU-bound work with Worker Threads

Synchronous CPU work freezes the loop and all requests; offload to a Worker, communicate via messages or SharedArrayBuffer, use a pool.

intermediate1 min read

Why package-lock.json must be committed

Lockfile pins exact versions of the whole dependency tree including transitive deps; guarantees identical installs across machines and CI.

intermediate1 min read

Choosing between CommonJS and ES Modules

ESM is the standard with static import/export and top-level await; set type to module; CJS uses require and module.exports and is synchronous.

intermediate1 min read

Layered structure for a scalable Express API

Routes map URLs, controllers handle HTTP, services hold business logic, data layer talks to the DB; keep each layer ignorant of HTTP except controllers.

intermediate1 min read

SemVer and the caret vs tilde range operators

MAJOR.MINOR.PATCH signals breaking/feature/fix; caret allows minor and patch updates, tilde allows only patch; use tilde for tighter control.

intermediate1 min read

Output order of sync, microtask, and macrotask

C runs first synchronously, then B drains from the microtask queue, then A from the macrotask queue.

intermediate1 min read

Running independent requests with Promise.all and race

Start all requests then await Promise.all to get all results or fail fast on first rejection; use Promise.race when only the fastest settled result matters.

intermediate1 min read

Handling async errors in Express middleware

Await inside try/catch and call next(err) on failure, or wrap the handler in an async error adapter; never let a rejected Promise go uncaught.

intermediate1 min read

Comparing the three async error-handling styles

Callbacks pass err as first arg; Promises route errors to catch; async/await uses try/catch; an unhandled rejection can crash the Node process.

intermediate1 min read

Counting lines in a 5GB log file efficiently

ReadFile loads all 5GB into RAM and may exceed buffer limits, instead stream with createReadStream plus readline and count line by line.

intermediate1 min read

Reading a POST body from the request stream

Body arrives in chunks via data events, accumulate them, on the end event concatenate and JSON.parse inside try/catch.

intermediate1 min read

path.resolve vs path.join

Join concatenates and normalizes relative segments, resolve builds an absolute path right to left from cwd and resets on any absolute segment.

intermediate1 min read

fs.watch vs fs.watchFile

Watch uses OS event notifications, efficient but inconsistent across platforms, watchFile polls stat at an interval, reliable but slower.

intermediate1 min read

Parsing JSON bodies with express.json

Register express.json via app.use so it reads the request stream and populates req.body before handlers run, place it before routes.

intermediate1 min read

res.send vs res.json vs res.end

Send is flexible and sets content type by type, json serializes and sets JSON content type, end is the raw http terminator with no body helpers.

intermediate1 min read

Express route order and matching

Express checks routes in definition order, /items/new matches the literal route first, if /:id came first new would be captured as an id.

intermediate1 min read

Application-level vs router-level middleware

App.use() binds to the app and runs everywhere; router.use() binds to a Router and runs only for that router's routes.

intermediate1 min read

Express error-handling middleware signature

(err, req, res, next) with err first, identified by arity, placed last after all routes.

We are hiring for this. Every open role lists the topics its interview covers, so you can prepare for the real thing rather than guessing.

See open roles