We use analytics and advertising cookies to understand how the site is used and whether our ads on Facebook and Instagram work. They are set only if you accept. See our Privacy Policy for details.
Practice Node.js interview questions on the event loop phases, process.nextTick and setImmediate, the libuv thread pool, streams and backpressure, CommonJS vs ES modules, worker threads and child processes, and memory leaks.
Answer a real Node.js interview question before you browse the list. No signup needed.
nums = [1, 2, 2, 3]
for n in nums:
if n % 2 == 0:
nums.remove(n)
What is nums afterwards?
Practice in a session
10 questions from Node.js, one after another, then your score and streak.
The event loop and its phases (timers, poll, check), how process.nextTick and promise callbacks are ordered, what the libuv thread pool handles (fs, dns.lookup, crypto) and what it does not (network sockets), streams and backpressure, CommonJS vs ES modules and package.json exports, error handling for async code, and scaling across cores with cluster or worker_threads.
Your JavaScript runs on one thread per event loop, but Node.js is not single-threaded overall: libuv runs a thread pool (4 threads by default, UV_THREADPOOL_SIZE to change it) for file system work, dns.lookup and some crypto, and worker_threads give you extra JavaScript threads with their own event loops. CPU-heavy JavaScript on the main thread still blocks every other request.
process.nextTick callbacks run as soon as the current operation finishes, before promise callbacks and before the event loop moves on, so recursive nextTick calls can starve I/O. setImmediate callbacks run in the check phase of the next loop iteration, after I/O polling. Inside an I/O callback, setImmediate always fires before a setTimeout of 0; at the top level of a script their order is not guaranteed.
A Writable buffers data up to its highWaterMark; write() returns false once the buffer is past that mark, and the producer should pause until the 'drain' event. pipe() and stream.pipeline() handle this for you, and pipeline() also forwards errors and cleans up every stream in the chain, which is why it is preferred over chained pipe() calls.
Both. Most production code still contains CommonJS, while new packages ship ES modules. Interviewers ask how the two interoperate (importing a CommonJS package gives you module.exports as the default export), how the package.json type and exports fields decide what loads, why ESM imports are live bindings, and why require is not defined inside an ES module.