NewWork mode: your Claude Code or Codex on work calls, answering from your project's codeSkip to content

Quiz: Node.js

Node.js questions from real interviews as a quiz, with an explanation for every option.

33 questionsAll topicsNode.js

Try it: 5 questions

Loading…

Sample questions

  1. What happens if code accesses a let variable before its declaration is executed in the current scope?

    • A SyntaxError is thrown before the program starts.
    • The variable is automatically assigned null.
    • A ReferenceError is thrown because the variable is in the TDZ.
    • It returns undefined, as an access to a var variable would.
    Full answer
  2. How does Node.js typically perform asynchronous file-system operations such as fs.readFile?

    • It submits the operation to the libuv thread pool and runs the JavaScript callback on the main thread.
    • It sends the operation to a separate Node.js process that returns the result.
    • It performs the operation synchronously on the main thread but postpones the callback.
    • It runs both the operation and the callback in a separate JavaScript thread.
    Full answer
  3. When should you typically optimize JavaScript code in a Node.js application?

    • After every code change, regardless of its performance impact
    • Before implementing the core functionality, to prevent any delays from the start
    • After implementing the core functionality, once metrics reveal bottlenecks
    • Only after the application has been running in production for a long time
    Full answer
  4. What is the primary function of a Button in a user interface?

    • Store user data on the server
    • Set the position of other elements on the page
    • Trigger an action when the user clicks it
    • Display static text without interaction
    Full answer
  5. Can a resource identifier be sent in the body of a POST request?

    • No, an identifier can only be sent in the URL.
    • Yes, but the server must use the supplied ID instead of generating its own.
    • No, POST requests can contain only fields without an identifier.
    • Yes, if the API contract allows it; the server can accept that ID.
    Full answer
  6. What is the primary role of controllers in Nest.js?

    • Accept HTTP requests, route their handling, and return responses to clients.
    • Run application business logic independently of HTTP requests.
    • Store application data and manage its persistence in a database.
    • Configure dependencies and wire application components together.
    Full answer
  7. What happens to the promise returned by Promise.all if one of its input promises rejects?

    • It rejects with the same reason and cancels the other promises.
    • It waits for the other promises to settle, then rejects with the first error.
    • It ignores the error and resolves with the results of fulfilled promises.
    • It rejects with the same reason, while the other promises keep running.
    Full answer
  8. What is a thread pool in Node.js?

    • A set of reusable worker threads that take tasks from a queue.
    • A set of separate Node.js processes started to handle requests.
    • A mechanism that starts a new thread for every incoming task.
    • An event queue where the Event Loop runs JavaScript code in sequence.
    Full answer
  9. Which statement correctly describes var in JavaScript?

    • The variable is function-scoped and may be accessed before its declaration line because of hoisting.
    • The variable is block-scoped, but is hoisted only within the block.
    • The variable is block-scoped and accessible only inside {}.
    • The variable is globally scoped regardless of where it is declared.
    Full answer
  10. What is the main difference between Node.js clustering and launching processes with child_process?

    • A cluster starts processes one at a time, while child_process automatically distributes incoming connections among them.
    • A cluster starts server workers and distributes connections among them, while child_process is for launching separate programs and tasks.
    • A cluster uses multiple threads within one process, while child_process creates processes only for HTTP requests.
    • A cluster launches separate programs, while child_process creates HTTP server copies and distributes connections among them.
    Full answer