Skip to content
tezvyn:

Top 30 Node.js & Express Concepts Quiz

30 multiple-choice questions on the Node.js & Express fundamentals, drawn from 30 bites in the Node.js & Express 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.

  1. Question 1 of 30

    What is the primary function of the V8 engine within environments like Chrome or Node.js?

    Show the answer

    Answer: c · To translate JavaScript code into native machine code for fast execution.

    V8's core role is to compile JavaScript into native machine code, enabling high-performance execution. While environments like Node.js provide APIs for interactions (option D), V8 itself is solely the engine responsible for processing the JavaScript code.

    Read the full bite: V8: The Engine Powering Chrome and Node.js

  2. Question 2 of 30

    For which type of task would Node.js's event-driven model, relying on EventEmitter, typically be least effective?

    Show the answer

    Answer: a · Performing intensive image manipulation or video encoding.

    The event-driven model is least effective for CPU-bound tasks like image manipulation because they block the single-threaded event loop. It excels at I/O-bound tasks such as network requests, database queries, and file operations.

    Read the full bite: Node.js Events and the EventEmitter

  3. Question 3 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

  4. Question 4 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.

    Read the full bite: Event Loop vs Crypto Module

  5. Question 5 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

  6. Question 6 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

  7. Question 7 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

  8. Question 8 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

  9. Question 9 of 30

    How does Libuv ensure non-blocking I/O for operations that lack native asynchronous support from the operating system?

    Show the answer

    Answer: c · It uses a dedicated thread pool to execute these operations, preventing the main JavaScript thread from blocking.

    Libuv employs a thread pool for I/O operations that do not have native asynchronous OS APIs, allowing these tasks to run in the background without blocking the main JavaScript event loop. Relying on the main thread or just JavaScript Promises would not achieve true non-blocking I/O at the system level.

    Read the full bite: Libuv: The Engine Behind Node.js Async I/O

  10. Question 10 of 30

    For which task would Node.js Worker Threads provide the most significant benefit?

    Show the answer

    Answer: c · Processing a large video file to apply a filter.

    Worker threads are specifically designed for CPU-bound operations like video processing to offload heavy computation from the main thread. I/O-bound tasks, such as database queries or network requests, are already efficiently managed by Node's event loop and do not benefit from worker threads.

    Read the full bite: Worker Threads: True Parallelism in Node.js

  11. Question 11 of 30

    What is the primary advantage of employing the Node.js cluster module in a multi-core environment?

    Show the answer

    Answer: c · It allows a single Node.js application to utilize all available CPU cores for I/O-bound network operations on one machine.

    The cluster module's core purpose is to enable a single Node.js application to fully utilize all CPU cores on a *single* multi-core machine for I/O-bound tasks like network applications. It is not designed for direct memory sharing (that's worker_threads), distributing across multiple physical servers, or low-overhead IPC for frequent data exchange, as IPC overhead is noted as high.

    Read the full bite: Node.js Cluster: Scaling on a Single Machine

  12. Question 12 of 30

    According to the CommonJS mental model, what is the default state of variables and functions defined within a module file?

    Show the answer

    Answer: b · They are private to the module unless explicitly exported.

    The card states, "By default, all tools and materials (variables, functions) inside are private. To share a tool, you place it on a public shelf called exports." This means they are private unless explicitly exported. Options A and B describe the opposite of CommonJS's encapsulation, and D is incorrect because variables are accessible within their own module before any import.

    Read the full bite: CommonJS: Node.js's Original Module System

  13. Question 13 of 30

    What is the primary function of the package.json file when a new developer sets up a Node.js project?

    Show the answer

    Answer: d · It lists all external code the project depends on and defines how to run common tasks.

    The correct answer is B because package.json explicitly lists all external libraries (dependencies) required for the project and defines runnable scripts. This allows a new developer to quickly install everything with 'npm install' and run tasks like 'npm start', making the project self-contained and reproducible. Option B is incorrect because while package.json can suggest a Node.js version, its primary role for initial setup is dependency and script management.

    Read the full bite: package.json: The Blueprint for Your Node.js Project

  14. Question 14 of 30

    What is the main reason for differentiating between "dependencies" and "devDependencies" in a Node.js project?

    Show the answer

    Answer: c · To reduce the final production bundle size and enhance security.

    The card states this separation "prevents shipping unnecessary code to production, which saves disk space, reduces installation time, and minimizes the potential security attack surface." Option D is incorrect because the distinction aims to exclude development tools from production, not include them, to avoid bloat and security risks.

    Read the full bite: Dependencies vs. DevDependencies: What's the Difference?

  15. Question 15 of 30

    What is the primary mechanism that allows npm scripts to execute project-specific tools (like jest or webpack) without requiring them to be installed globally?

    Show the answer

    Answer: a · npm temporarily adds the project's node_modules/.bin directory to the system's PATH during script execution.

    The card states that npm temporarily adds the project's node_modules/.bin directory to the system's PATH, allowing local executables to be run by name. Option C is incorrect because npm does not automatically install global dependencies for scripts.

    Read the full bite: npm Scripts: Your Project's Command-Line Shortcuts

  16. Question 16 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

  17. Question 17 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

  18. Question 18 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

  19. Question 19 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

  20. Question 20 of 30

    If module A requires B, and B subsequently requires A, what does Node.js provide to B for A's exports when A was the module initially loaded?

    Show the answer

    Answer: a · An empty object or a partially populated module.exports object from A.

    To prevent an infinite loop, Node.js returns the module.exports object from A as it exists at that moment, which is often incomplete. It does not immediately crash or provide a fully resolved object, but rather an unfinished version that can lead to later TypeErrors.

    Read the full bite: Node.js Circular Dependencies: The Unfinished Export

  21. Question 21 of 30

    What is the primary advantage of using an NPM scope (e.g., @my-org/package) for your packages?

    Show the answer

    Answer: b · It allows you to publish private packages and organize related modules under a shared namespace.

    Option B accurately describes the core benefits of NPM scopes: they are mandatory for publishing private packages and provide a way to group related modules under a common, unique namespace. Option D is incorrect because the card states that scoped packages are public by default and require a specific flag for private access.

    Read the full bite: NPM Scopes: Namespacing Packages to Avoid Collisions

  22. Question 22 of 30

    When is it inappropriate to use a callback in Node.js?

    Show the answer

    Answer: a · When you must have a result before the next line runs

    The card explicitly warns against using callbacks when you need a result immediately before moving on, because they are designed for deferred, non-blocking execution. The other three options are all I/O scenarios where callbacks are the recommended pattern.

    Read the full bite: Node.js Callbacks: Functions That Run Later

  23. Question 23 of 30

    In JavaScript's single-threaded environment, what is the main problem Promises are designed to address?

    Show the answer

    Answer: a · To prevent the user interface from freezing during network requests or file I/O.

    Promises were created to manage asynchronous operations gracefully, allowing other code to run without blocking the main thread, which prevents the user interface from freezing during long-running tasks like network requests. Option C is incorrect because JavaScript remains single-threaded; Promises manage non-blocking I/O, not true parallel CPU execution.

    Read the full bite: JavaScript Promises: Handling Future Values

  24. Question 24 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

  25. Question 25 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.

    Read the full bite: Promise .catch(): Handling Rejections

  26. Question 26 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

  27. Question 27 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

  28. Question 28 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

  29. Question 29 of 30

    When using Promise.race() for a network request with a timeout, what is the outcome if the timeout promise rejects before the network request resolves?

    Show the answer

    Answer: d · The Promise.race() promise will reject with the timeout's error.

    Promise.race() settles with the outcome of the very first promise to settle, regardless of whether it resolves or rejects. If the timeout promise rejects first, the race() promise immediately rejects with that error. The network request's eventual resolution is ignored because it was not the first to settle.

    Read the full bite: Promise.race(): First Promise to Settle Wins

  30. Question 30 of 30

    What is the primary reason to use Promise.allSettled() over Promise.all() for multiple asynchronous tasks?

    Show the answer

    Answer: a · To obtain a status report for every task, allowing individual handling of successes and failures.

    Promise.allSettled() is designed to provide an outcome for every promise in the batch, whether it fulfilled or rejected, allowing for graceful handling of partial failures. Option C describes Promise.all(), which short-circuits and rejects the entire batch if any promise fails.

    Read the full bite: Promise.allSettled(): Never Fail a Batch of Promises

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.

Get it on Google PlayiPhone app coming soon