Node.js Cheat Sheet 2026
The 30 highest-yield Node.js facts, distilled from real exam questions. Print it, save it as a PDF, or study it here — free, no sign-up.
65 questions
120 min time limit
68.00% to pass
- What is the professional approach to structuring a large Node.js application to promote maintainability? → Organize code into feature-based or layer-based modules with clear separation of concerns
- What does res.sendStatus(204) send to the client? → Status 204 with the default status message as the body
- What is the purpose of calling next(err) inside an Express middleware? → Passes control to the next error-handling middleware
- Which assertion style does Chai's `expect` interface use? → Chainable getter-based natural language assertions
- What does 'graceful shutdown' mean in the context of a professional Node.js service? → Stopping acceptance of new requests, finishing in-flight requests, then exiting cleanly
- In the Node.js event loop, the `check` phase is dedicated to executing callbacks registered by which function? → setImmediate()
- _________ is a Node.js debugging tool with a graphical user interface. → Node Inspector
- A stakeholder wants API documentation auto-generated from your Express.js codebase. Which tool is most commonly used? → Swagger/OpenAPI via swagger-jsdoc and swagger-ui-express
- What is the purpose of `mongoose.connection.on('error', handler)` in a Node.js application? → To catch post-connection errors such as network drops
- A Node.js service receives a JWT and verifies it using jwt.verify(token, secret). What risk does omitting the algorithms option introduce? → Algorithm confusion attacks, including the 'none' algorithm bypass
- What does the caret (`^`) range in `"express": "^4.18.0"` allow? → Any version >=4.18.0 and <5.0.0
- What event does a Readable stream emit after all data has been consumed and the stream has closed? → 'end'
- Which Express built-in middleware parses URL-encoded form bodies? → express.urlencoded()
- In the REPL session, the Underscore Variable is used → to get the last result.
- What is the role of the `libuv` library in the Node.js architecture? → Provides the event loop and async I/O abstractions across platforms
- What is the main purpose of Istanbul (nyc) in a Node.js project? → To instrument JavaScript code and measure how much of it is covered by tests
- Which Node.js built-in module provides the `assert.deepStrictEqual()` method for comparing objects in tests? → assert
- In Prisma, what command regenerates the Prisma Client after modifying `schema.prisma`? → prisma generate
- Which async iteration construct should you use to consume a Node.js Readable stream line by line in modern Node.js? → for await...of with the stream
- What does the `path.resolve()` method return? → An absolute path by processing the sequence of paths from right to left
- What is a 'starvation' risk when using `process.nextTick()` recursively? → It can prevent the event loop from ever reaching the I/O poll phase
- How do you view all globally installed npm packages? → npm list -g --depth=0
- A Node.js stream pipeline processes compressed user uploads. What denial-of-service risk must be mitigated? → Zip bombs: tiny compressed input expanding to gigabytes, exhausting memory
- What does setting `"strict": true` in a TypeScript `tsconfig.json` enable for QA purposes? → A set of strict type-checking flags that catch more potential bugs at compile time
- What does `sinon.stub()` return when called without a replacement implementation? → A stub that returns `undefined` by default
- What does the Node.js community consider a best practice for handling asynchronous errors in Express middleware? → Passing errors to next(err) so Express's error-handling middleware can process them
- What is the output of this code? ``` async function main() { throw new Error('oops'); } main().catch(e => console.log(e.message)); ``` → oops
- Which tool is commonly used to enforce consistent code formatting in Node.js projects? → Prettier
- What is the default string encoding used when creating a Buffer from a string in Node.js? → utf8
- What does the `--inspect` flag do when starting a Node.js application? → Enables the V8 inspector protocol for debugging
Turn these facts into recall:
Was this helpful?