Skip to content
tezvyn:

Top 30 Easy Node.js & Express Concepts Quiz for Beginners

30 easy multiple-choice Node.js & Express concept questions, the vocabulary and first principles, the parts you need before anything else makes sense. They come from 30 bites in the Node.js & Express library, the gentlest 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.

  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

    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

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

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

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

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

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

  9. Question 9 of 30

    Which action is crucial for a Node.js HTTP server to signal that a response has been fully sent to the client?

    Show the answer

    Answer: c · Invoking response.end() on the response object.

    The card explicitly states that `response.end()` is critical to signal that the response is complete, otherwise the client will hang indefinitely. While `response.write()` sends data, it does not close the connection or mark the response as finished.

    Read the full bite: Creating a Basic HTTP Server in Node.js

  10. Question 10 of 30

    What is the primary drawback of using synchronous file I/O in a Node.js web server?

    Show the answer

    Answer: c · It blocks the event loop, making the entire server unresponsive to other requests.

    Synchronous I/O blocks Node.js's single-threaded event loop, preventing it from processing other tasks or requests, which makes the server unresponsive. While asynchronous I/O allows the application to remain responsive, the actual file reading speed from disk is not inherently faster than synchronous methods.

    Read the full bite: Node.js File I/O: Synchronous vs. Asynchronous

  11. Question 11 of 30

    Under which circumstance would directly using __dirname in a Node.js script result in a ReferenceError?

    Show the answer

    Answer: b · The Node.js project is configured to use ES Module syntax (e.g., import/export).

    The card explicitly states that __dirname does not exist in ES Modules, and attempting to use it in such a context will cause a ReferenceError. Other options describe scenarios that are either the problem __dirname solves or unrelated to its availability.

    Read the full bite: __dirname and __filename: Path Anchors in Node.js

  12. Question 12 of 30

    Which task is the Node.js os module primarily designed to help with?

    Show the answer

    Answer: d · Querying the host system's hardware and operating system details.

    The os module is designed for querying static system properties and environment details like CPU cores, memory, and platform type. Tasks like managing environment variables, path manipulation, or interacting with the Node.js process itself are handled by other modules like process or path.

    Read the full bite: Node.js os Module: Reading Your System's Vital Signs

  13. Question 13 of 30

    What is the main advantage of using Express.js compared to Node.js's native HTTP module for building web servers?

    Show the answer

    Answer: d · It simplifies the process of defining routes, applying middleware, and handling responses.

    The card states Express was created to simplify routing, middleware, and response handling, which are verbose with Node's native HTTP modules. Express itself is unopinionated about databases or project structure, and WebSocket support is not its primary advantage over native HTTP.

    Read the full bite: Creating Your First Express Server

  14. Question 14 of 30

    How does Express.js determine which specific handler function to execute for an incoming web request?

    Show the answer

    Answer: d · By matching both the HTTP method and the URL path of the request.

    Express routing connects a request's path and HTTP method to a specific handler function. It requires both components to uniquely identify and execute the correct handler, as stated in the card: 'Each route matches a unique combination of an HTTP method and a URL path.' Options A and C are incomplete, as they only consider one part of the matching criteria. Option A describes a general execution order, not the specific matching logic for a route.

    Read the full bite: Express.js: Basic Request Routing

  15. Question 15 of 30

    What is a critical pitfall to avoid when using the `res` object in an Express route handler?

    Show the answer

    Answer: b · Sending multiple HTTP responses for a single client request.

    The card explicitly warns against sending more than one response per request, as it closes the connection and leads to errors. While other options describe common mistakes, they are either syntax issues, misunderstandings of object roles, or not critical errors in the same way.

    Read the full bite: Express Request and Response Objects (req, res)

  16. Question 16 of 30

    What is the primary outcome if an Express middleware function completes its execution without calling next() or sending a response?

    Show the answer

    Answer: a · The client's request will remain open, eventually timing out without a response.

    The card states that if next() is not called and no response is sent, 'the request will hang and eventually time out,' meaning the client waits indefinitely. The server does not automatically terminate or redirect the request; it simply waits for the middleware to complete its cycle.

    Read the full bite: Express Middleware: Intercepting Requests Before Your Route Handler

  17. Question 17 of 30

    According to the card, what is the primary benefit of applying REST principles to a distributed system?

    Show the answer

    Answer: c · It allows components to evolve independently and the system to scale efficiently.

    The card explicitly states that REST's constraints enable "independent component deployment" and "scalable interactions," allowing the system to "grow, evolve, and remain stable." Option D is incorrect because REST is an architectural style, not a strict protocol, emphasizing flexibility rather than rigidity.

    Read the full bite: REST: The Architectural Style of the Web

  18. Question 18 of 30

    When a server receives an API request where the client has omitted a mandatory piece of information in the request body, which HTTP status code class is most appropriate for the server to return?

    Show the answer

    Answer: c · 4xx, as the client's request itself is flawed or incomplete.

    The card explains that 4xx codes indicate a client error, meaning the client made a mistake, such as sending a malformed request or missing required data. A 5xx code would signal a server-side issue, which is not the case when the client's input is incorrect.

    Read the full bite: HTTP Status Codes: The Server's Signal

  19. Question 19 of 30

    Which scenario best describes when an ODM is a poor fit for your project?

    Show the answer

    Answer: a · A high-throughput system requiring precise, manually optimized control over every database query

    The card explicitly warns against using ODMs when you need precise query control for performance reasons, making C the correct choice. Option D is a tempting distractor because an Express app with multiple developers is actually listed as an ideal scenario where an ODM shines.

    Read the full bite: ODM: Your Database as JavaScript Objects

  20. Question 20 of 30

    Given its synchronous API and embedded design, which workload is node:sqlite best suited for?

    Show the answer

    Answer: c · A local CLI utility that logs events to a file without extra npm dependencies

    node:sqlite is designed for lightweight, local structured storage such as CLI tools that avoid external dependencies, whereas a high-traffic API is a poor fit because DatabaseSync executes synchronously and blocks the event loop.

    Read the full bite: Node.js Built-in SQLite Driver

  21. Question 21 of 30

    What is the most critical reason to ensure client.close() is called after completing database operations?

    Show the answer

    Answer: c · To prevent resource leaks and free up network connections.

    The card explicitly highlights that failing to call client.close() is a 'footgun' that leads to 'resource leaks in your application' and that it's 'crucial' for freeing up resources.

    Read the full bite: Connecting to MongoDB with the Native Node.js Driver

  22. Question 22 of 30

    A user has successfully proven their identity to a system. What concept then determines whether they can perform a specific action, like editing a profile?

    Show the answer

    Answer: c · Authorization

    Authorization is the process of checking what actions a verified user is permitted to perform ('what can you do?'). Authentication, the most tempting distractor, is the initial step of proving identity ('who are you?'), which the question states has already been successfully completed.

    Read the full bite: Authentication vs. Authorization: Who You Are vs. What You Can Do

  23. Question 23 of 30

    In an error-first callback, what is the specific purpose of the very first argument?

    Show the answer

    Answer: d · To signal the presence of an error or the successful completion of the task.

    The card states that the first parameter is "always an Error object (or null if no error occurred)," which means it signals whether an error occurred or if the task completed successfully. Option C is incorrect because successful data is passed in subsequent arguments, not the first.

    Read the full bite: Error-First Callbacks: Node.js's Original Async Handler

  24. Question 24 of 30

    What is the primary benefit of implementing custom error classes in an application, especially for APIs?

    Show the answer

    Answer: d · They allow for reliable, type-based differentiation of failure modes, enabling specific responses.

    The card emphasizes that custom error classes provide explicit, typed categories for failures, allowing consuming code (like API middleware) to reliably differentiate between various failure types (e.g., using 'instanceof') and send appropriate responses. While preventing crashes is a goal of error handling, it's not the primary, unique benefit of *custom* error classes over generic ones, which also allow for caught errors.

    Read the full bite: Custom Error Classes: Beyond Generic Errors

  25. Question 25 of 30

    What is the primary advantage of Jest's "batteries-included" design philosophy?

    Show the answer

    Answer: c · It provides a comprehensive, integrated toolkit for test running, assertions, and mocking, simplifying setup.

    The card explains that Jest's 'batteries-included' approach means it bundles a test runner, assertion library, and mocking system into one integrated solution, simplifying what was previously a complex setup. Option D describes a performance feature, not the core benefit of its integrated design.

    Read the full bite: Jest: A Batteries-Included JavaScript Test Framework

  26. Question 26 of 30

    Which task is Mocha *not* primarily responsible for in a JavaScript testing setup?

    Show the answer

    Answer: a · Providing built-in functions to compare actual vs. expected values.

    Mocha is a test runner that provides structure, manages execution, and handles asynchronous tests. However, it explicitly states that it does not provide assertion functions; these must be imported from a separate library like Chai.

    Read the full bite: Mocha: A Flexible JavaScript Test Runner

  27. Question 27 of 30

    Which of the following is a primary reason why the "should" assertion style is often avoided in modern JavaScript testing?

    Show the answer

    Answer: b · It modifies global object prototypes and can fail silently when asserting on null or undefined values.

    The card explicitly states that the "should" style is often avoided because it modifies a global prototype and fails silently on null and undefined variables. While readability is a factor in choosing assertion styles, the silent failure and prototype modification are the critical technical drawbacks mentioned.

    Read the full bite: Chai: Assertions for Readable JavaScript Tests

  28. Question 28 of 30

    Why is it critical that output encoding for XSS prevention is context-aware?

    Show the answer

    Answer: c · Different output locations (like HTML body vs. script tag) interpret special characters differently.

    The correct answer is B because browsers interpret special characters differently depending on whether they are in an HTML tag, an attribute, or a script block, requiring specific encoding for each context. Option D is a common misconception, as encoding modifies characters to prevent execution, not to preserve their literal form if it's malicious.

    Read the full bite: XSS Prevention: Context-Aware Output Encoding

  29. Question 29 of 30

    Which of the following best describes how parameterized queries prevent SQL injection vulnerabilities?

    Show the answer

    Answer: b · They separate the SQL query's structure from user-provided data, ensuring the input is treated only as values for placeholders.

    Parameterized queries work by sending the SQL command structure and user data separately to the database. This ensures the database treats user input strictly as data to fill placeholders, preventing it from being executed as part of the query's logic. Filtering (option C) is an unreliable defense as it's difficult to catch all malicious inputs.

    Read the full bite: Preventing SQL Injection: Never Trust User Input

  30. Question 30 of 30

    Which of the following is a key limitation of npm audit?

    Show the answer

    Answer: a · It only identifies security flaws that have been previously reported and added to a database.

    npm audit's primary limitation is that it only flags code with known vulnerabilities from a public database; it does not find new bugs or zero-day exploits. It can detect vulnerabilities in transitive dependencies, contrary to a common misconception.

    Read the full bite: Dependency Scanning with npm audit

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