Node.jsworking

How does the Node.js event loop differ from the browser loop in an interview answer?

Timers, poll, and check phases matter; blocking the loop still freezes the process.

Points worth saying

  • Node still has one main thread for JavaScript.
  • Phases schedule timers, I/O callbacks, and setImmediate.
  • CPU-heavy sync work blocks every connection, not only one request.

A full answer

Node runs JavaScript on one main thread. Libuv handles the loop and a thread pool for some I/O. Your async code still returns to that one thread when the callback runs.

Interviewers often want phase awareness: timers, pending callbacks, poll, check (setImmediate), and close callbacks. You do not need to recite every detail, but you should know that a long sync loop prevents timers and I/O callbacks from running.

For CPU work, move it off the main thread with a worker, a child process, or a separate service. For I/O, keep using async APIs. Saying “Node is single-threaded, so we never use threads” is incomplete; the point is what you keep off the event loop.

Mark your progress

Create a practice profile to mark this question.