Node.js is a JavaScript runtime built on Chrome's V8 engine. It lets you run JS outside the browser — on a server, your machine, scripts, etc.
Key characteristics: single-threaded, non-blocking I/O, event-driven. It doesn't wait for disk reads or network calls — it registers a callback and moves on. This makes it very efficient for I/O-heavy tasks (APIs, file servers, real-time apps) but not great for CPU-heavy tasks (image processing, ML inference) which block the thread.
The event loop in Node works the same way as in the browser but has extra phases: timers → pending callbacks → idle/prepare → poll (I/O) → check (setImmediate) → close callbacks. process.nextTick() fires before any phase transition — highest priority after current operation.
setImmediate(fn) — fires in the check phase, after I/O. setTimeout(fn, 0) — fires in timers phase. In I/O context, setImmediate always fires before setTimeout(fn, 0).