Test yourself under real exam conditions: 50 timed questions, 60 on the clock, pass mark 70%%. Instant score with a full review of everything you got wrong. Free — no account needed.
Exam details
Node.js is a JavaScript runtime built on Chrome's V8 engine. It allows running JavaScript outside the browser, using an event-driven, non-blocking I/O model that makes it lightweight and efficient for building scalable network applications.
The event loop is the mechanism that allows Node.js to perform non-blocking I/O operations despite JavaScript being single-threaded. It continuously checks the call stack and callback queue, executing callbacks when the stack is empty. Phases include: timers → pending callbacks → idle/prepare → poll → check → close callbacks.
setTimeout and setInterval callbackssetImmediate callbackssocket.on('close')setImmediate() executes in the check phase of the event loop, after the poll phase completes. setTimeout(fn, 0) executes in the timers phase on the next iteration. When called within an I/O callback, setImmediate() always fires before setTimeout().
process.nextTick() fires immediately after the current operation, before the event loop continues. It is processed on the microtask queue, not part of any event loop phase. setImmediate() fires on the next iteration of the event loop. Overusing nextTick can starve I/O.