Explain the event loop in Node.js. What are its phases?
The event loop repeatedly processes queues of completed operations in phases: timers for setTimeout and setInterval, pending callbacks, poll for incoming I/O, check for setImmediate, and close callbacks. Between every phase Node drains the microtask queue — process.nextTick first, then promise callbacks. This is why a long synchronous function blocks every request on the server: nothing else can run until it returns.