Top 30 Intermediate Node.js & Express Concepts Quiz
30 intermediate multiple-choice Node.js & Express concept questions, the mechanics underneath the basics: how the pieces relate and where the usual mental model stops holding. They come from 30 bites in the Node.js & Express library, the middle slice of the 142 Node.js & Express concept questions in the library. Answer them here or read straight down. Every question carries the correct option, why it is correct, and a link to the bite it came from.
Node.js, Express, Fastify, NestJS, Bun, Deno
30 questions. Pick an answer, or open “Show the answer” to read it.
Answers are graded in your browser. Nothing is saved, and no XP or streak is earned here. The app keeps score.
Question 1 of 30
What is the primary consequence of running a long-running synchronous task in a Node.js application?
Show the answer
Answer: a · The application's event loop will become blocked, making the server unresponsive.
The card states that a long-running synchronous computation will 'monopolize the single main thread, blocking the event loop entirely,' leading to an unresponsive application. Synchronous tasks are not automatically offloaded to background threads; they execute directly on the main thread, unlike asynchronous I/O operations.
Read the full bite: The Node.js Event Loop: Concurrency on a Single Thread
Question 2 of 30
A Node.js API stops responding to every request whenever a user logs in, because the login handler calls crypto.pbkdf2Sync to verify a password. What is the most likely cause?
Show the answer
Answer: b · The synchronous call runs on the single main thread and blocks the event loop until it finishes
pbkdf2Sync executes directly on the same thread that runs the event loop, so nothing else can be processed until it returns; the threadpool default is four, not zero, and the block has nothing to do with database connections.
Question 3 of 30
What is the primary benefit of splitting a CPU-intensive synchronous operation into smaller pieces using setTimeout(fn, 0)?
Show the answer
Answer: b · To allow the browser to process UI updates and user input between task segments.
The card states that splitting work with setTimeout(fn, 0) allows yielding control back to the event loop, enabling the browser to process user input and render updates, keeping the UI alive. Option A is incorrect because this technique adds overhead and does not necessarily speed up the overall execution time; its purpose is responsiveness, not raw speed.
Read the full bite: JavaScript's Event Loop: Macrotasks & Microtasks
Question 4 of 30
Which statement accurately describes how process.nextTick() callbacks are prioritized within the Node.js event loop?
Show the answer
Answer: b · They execute immediately after the current JavaScript operation, before any timers or I/O.
process.nextTick() callbacks are processed with the highest precedence, immediately after the current JavaScript operation completes and before the event loop proceeds to microtasks, timers, or I/O. Option D is incorrect because nextTick callbacks are processed *before* the microtask queue.
Read the full bite: process.nextTick(): Cutting in Line on the Event Loop
Question 5 of 30
What is the fundamental problem Node.js streams are designed to solve for data handling?
Show the answer
Answer: a · Processing large datasets without exhausting system memory.
The card states streams were created to 'process data piece by piece, keeping memory usage low and constant regardless of the total data size' because loading large files entirely into memory is inefficient or impossible. While streams can simplify I/O (option D), their core purpose is memory efficiency for large data, and they are not ideal for random access (option C).
Read the full bite: Node.js Streams: Processing Data in Chunks, Not Blobs
Question 6 of 30
What is the primary advantage of using asynchronous child processes in Node.js?
Show the answer
Answer: d · To execute CPU-bound tasks without blocking the main event loop.
The card explicitly states that child processes solve the problem of CPU-intensive operations blocking the single-threaded event loop by offloading heavy work. Option B describes the purpose of worker_threads, not child processes.
Read the full bite: Node.js Child Processes: Escaping the Main Thread
Question 7 of 30
Which of the following is a significant change when migrating a Node.js project from CommonJS to ES Modules?
Show the answer
Answer: c · Module dependencies are statically analyzed before code execution.
The card states that ES Modules are a 'statically analyzable contract' where dependencies are mapped out before execution, a major shift from CommonJS's dynamic require(). Options A, B, and C are incorrect because ESM explicitly removes direct access to require(), __dirname, and __filename, and makes file extensions mandatory for relative imports.
Read the full bite: ES Modules in Node.js: The Modern `import` System
Question 8 of 30
When resolving a package, which source does npx check first before falling back to its cache or the network?
Show the answer
Answer: a · The local project's node_modules/.bin directory
npx prioritizes a local project binary to avoid unnecessary network requests, checking node_modules/.bin before its own cache or the registry. Option D is tempting because caching is a core feature, but local copies take precedence.
Read the full bite: npx: Execute Packages Without Installing Them
Question 9 of 30
When using a .env file for local development, what is the most critical step to prevent accidental exposure of sensitive information?
Show the answer
Answer: c · Ensuring the .env file is listed in your project's .gitignore
The card explicitly states that 'The biggest mistake is committing your .env file to Git, exposing all your secrets' and that your '.gitignore file must contain a line with .env to prevent committing secrets.' This makes preventing version control exposure the most critical step. Storing only non-sensitive data (D) contradicts the primary purpose of .env for secrets.
Read the full bite: Environment Variables: Config Outside Your Code
Question 10 of 30
What is the primary characteristic that distinguishes the Service Layer from the Web Layer?
Show the answer
Answer: d · It contains the core business logic, independent of HTTP specifics.
The card explicitly states the Service Layer "contains the core business logic, orchestrating tasks without knowing about HTTP," highlighting its independence from the web protocol. Option B describes the primary function of the Web Layer, which is concerned with HTTP requests and responses.
Read the full bite: Structuring Express Apps with Layered Architecture
Question 11 of 30
What is the fundamental mechanism by which Promise.then() enables sequential asynchronous operations?
Show the answer
Answer: a · Each call to .then() returns a new promise, whose resolution depends on the preceding handler's outcome.
The core mechanism for chaining is that every .then() call creates and returns a new promise, allowing the next step in the sequence to wait for the previous one's resolution. Option C describes the outcome but not the underlying mechanism of how this sequential execution is achieved. Option B describes a common misconception where multiple handlers attached to the *same* promise execute in parallel, not sequentially.
Read the full bite: Promise.then(): Each Call Returns a New Promise
Question 12 of 30
What is the primary risk of placing a .catch() block in the middle of a promise chain without implementing a specific recovery strategy?
Show the answer
Answer: b · It can lead to subsequent .then() blocks executing with potentially invalid or missing data, as if the error never occurred.
The card states that if a .catch() block mid-chain only logs an error without recovery, the promise it returns will be fulfilled, causing subsequent .then() blocks to execute as if successful, potentially leading to 'confusing bugs' with 'missing data'. Option D is incorrect because .catch() resolves by default unless an error is explicitly re-thrown.
Question 13 of 30
What is a significant limitation of util.promisify when used with callback-based functions?
Show the answer
Answer: a · It only resolves with the first successful value if the callback provides multiple.
The card states that "If a callback provides multiple success values, like (err, val1, val2), promisify will only resolve with val1." Option D is incorrect because util.promisify provides its own internal callback to check for errors, not relying on the original function's error handling implementation.
Read the full bite: Node.js util.promisify: From Callbacks to Promises
Question 14 of 30
When an await keyword is encountered inside an async function, what is its primary effect?
Show the answer
Answer: d · It pauses the execution of the async function, allowing other tasks to run, and resumes when the Promise settles.
The card explains that await acts as a 'pause and resume' button for the async function, allowing the JavaScript engine to do other work while the Promise settles, thus ensuring non-blocking behavior. Option C describes a blocking scenario, which async/await is designed to prevent.
Read the full bite: Async/Await: Write Non-Blocking Code That Reads Synchronously
Question 15 of 30
What is the immediate outcome when one of the promises provided to Promise.all() rejects?
Show the answer
Answer: c · The Promise.all() promise immediately rejects with the reason of the first failed promise.
Promise.all() has a 'fail-fast' behavior: if any single input promise rejects, the entire Promise.all() promise immediately rejects with the reason of that first failed promise. Option A describes the behavior of Promise.allSettled(), which waits for all promises to settle regardless of their outcome.
Read the full bite: Promise.all(): Wait for Multiple Promises at Once
Question 16 of 30
Which scenario best describes the appropriate use case for path.join()?
Show the answer
Answer: d · When you are combining path segments to build a path relative to a known base directory, such as a module's location.
path.join() is designed for constructing paths relative to a base directory you control, by concatenating segments and handling normalization. Option A and C describe the primary use cases and processing behavior of path.resolve().
Read the full bite: path.join() vs. path.resolve(): Concatenation vs. Calculation
Question 17 of 30
What is the main reason to use the WHATWG URL API instead of manual string manipulation for handling URLs?
Show the answer
Answer: b · It provides a structured object to safely parse, access, and modify URL components.
The WHATWG URL API's primary benefit is converting a raw URL string into a structured object, allowing safe and predictable access and modification of its components, thereby preventing common parsing errors and security vulnerabilities. It does not validate resource existence, encrypt data, or shorten URLs for performance.
Read the full bite: WHATWG URL API: Safely Parse URLs, Not Strings
Question 18 of 30
What is the consequence if an Express middleware function neither calls next() nor sends a response?
Show the answer
Answer: a · The client's request will hang indefinitely, awaiting a response.
The card states, "If a middleware does neither, the request hangs." This means the client will wait indefinitely for a response. Calling next() is explicitly required for the request to proceed to the next function in the chain, making option C incorrect.
Read the full bite: Express Middleware: The Chain of Command for Requests
Question 19 of 30
For which scenario is express.Router most beneficial in an Express application?
Show the answer
Answer: c · Structuring an application with numerous routes into modular, maintainable files.
express.Router is designed to solve the scaling problem of growing applications by allowing developers to break routes into modular files, making the application more organized and maintainable. While routers can apply middleware, their primary benefit isn't solely for a single global middleware, which can be handled by app.use() directly.
Read the full bite: express.Router: Group Routes into Modular Files
Question 20 of 30
Which scenario would make express-generator the LEAST suitable tool for initiating an Express project?
Show the answer
Answer: c · Creating a simple API server that primarily returns JSON responses.
The card explicitly states not to use express-generator for 'a minimal API server that doesn't require a view engine or a complex file structure,' which aligns with creating a simple API returning JSON. The other options describe scenarios where the tool is highly recommended.
Read the full bite: Scaffold an Express App with `express-generator`
Question 21 of 30
When a browser-based frontend on "app.com" fetches data from an Express API on "api.com", what is the `cors` middleware's primary function?
Show the answer
Answer: b · To add a specific header to the API's response, signaling to the browser that "app.com" can access the data.
The `cors` middleware's primary role is to add the `Access-Control-Allow-Origin` header to the API response, which acts as a permission slip for the browser to allow the frontend script to access the data. It does not block requests; the browser's Same-Origin Policy is what prevents access if the header is missing.
Read the full bite: CORS Middleware: Unlocking Cross-Origin Requests in Express
Question 22 of 30
Which scenario is most likely to cause a functional issue immediately after adding app.use(helmet()) to an Express app without further configuration?
Show the answer
Answer: d · The application loads scripts or styles from external domains like CDNs.
The default Content-Security-Policy (CSP) in Helmet is very strict, only allowing resources from the same origin ('self'). This will block common external resources like scripts from CDNs or Google Fonts, causing functional issues until the CSP is explicitly configured. While running without HTTPS can cause issues with 'upgrade-insecure-requests', the card highlights CSP configuration for external resources as the primary and most common 'footgun'.
Read the full bite: Helmet.js: Secure Express Apps with HTTP Headers
Question 23 of 30
Which logging task is NOT a primary use case for Morgan in an Express application?
Show the answer
Answer: c · Tracking internal application events like database connection failures.
Morgan is purpose-built for logging HTTP requests and responses, providing visibility into traffic patterns. It is explicitly stated that Morgan is not a general-purpose application logger and should not be used for internal application events like database errors, which require dedicated logging libraries.
Read the full bite: Morgan: One-Line Request Logging for Express
Question 24 of 30
When cookie-parser with a secret detects a tampered signed cookie, what happens?
Show the answer
Answer: d · The cookie's value is set to false within the req.signedCookies object.
The card explicitly states that a cookie failing signature validation will have its value set to false in req.signedCookies. This allows the application to detect tampering and decide how to proceed, rather than cookie-parser automatically rejecting the request or throwing an error.
Read the full bite: cookie-parser: From Header String to Usable Object
Question 25 of 30
In Mongoose, which component is primarily used to perform database operations like creating, querying, or updating documents?
Show the answer
Answer: a · The Model, which is compiled from a Schema and provides an interface to the database.
The Model is described as the 'active factory' and 'primary tool' for interacting with the database to create, query, update, and delete documents. The Schema, conversely, is a 'passive object' that only defines the structure, not the operations.
Read the full bite: Mongoose: Schemas are Blueprints, Models are Factories
Question 26 of 30
Which change to an API would most likely necessitate creating a new version?
Show the answer
Answer: d · Splitting a single 'address' field into 'street', 'city', and 'zipCode' fields.
The card states that 'breaking changes' alter data structures or endpoint behavior, citing splitting a 'fullName' field as an example. Splitting an 'address' field is analogous, requiring clients to adapt to new fields. Adding optional fields or new endpoints are non-breaking changes, and performance optimizations do not alter the API contract.
Read the full bite: API Versioning: Managing Change Without Breaking Clients
Question 27 of 30
What is the primary benefit of including hypermedia links (next, prev) in a paginated API response?
Show the answer
Answer: a · It reduces the client's need to construct pagination URLs, simplifying navigation logic.
The card explicitly states that hypermedia links allow the client to navigate without having to construct pagination URLs itself, keeping the logic on the server, which simplifies client-side navigation. Option D is incorrect because hypermedia links do not address data consistency issues in rapidly changing datasets; that's a separate challenge for simple pagination.
Read the full bite: API Pagination: Serving Big Datasets in Chunks
Question 28 of 30
When defining a relationship where a `Post` belongs to a `User` using `Post.belongsTo(User)`, where does Sequelize place the foreign key?
Show the answer
Answer: a · On the Post table, named userId.
The card states that for `A.belongsTo(A)`, the foreign key is placed on the source model, A. In this case, `Post` is the source model, so the `Post` table will receive the `userId` foreign key. A junction table is only used for many-to-many relationships.
Read the full bite: Sequelize Associations: Who Holds the Foreign Key?
Question 29 of 30
Which scenario best illustrates an appropriate use of Mongoose middleware?
Show the answer
Answer: b · Ensuring a user's password is consistently hashed before being stored in the database.
The card explicitly states that hashing passwords before saving a user document is a canonical use case for middleware, as it ensures this critical step always occurs. Option D is incorrect because the card warns that in query middleware like findOneAndUpdate, 'this' refers to the query object, not the document, making direct document field access problematic.
Read the full bite: Mongoose Middleware (Hooks): Intercepting Database Operations
Question 30 of 30
Which statement correctly distinguishes Mongoose validation from the 'unique' schema option?
Show the answer
Answer: b · Mongoose validation provides application-level data integrity checks, whereas the unique option configures a database index.
Mongoose validation is described as an application-layer guard for data integrity, while the unique option is explicitly stated to be a helper for building a database index, not a Mongoose validation rule. The unique option's enforcement happens at the database level, not as part of Mongoose's validation middleware.
Read the full bite: Mongoose Validation: Your Schema's Built-in Guard
Could you explain these out loud?
That is what an interview actually tests. Tezvyn gives you questions like these with what the interviewer is really checking, the answer that lands, and the mistake that ends the conversation, in the four minutes before your next meeting.
The iPhone app is on the way
We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.
Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.