Explain the event loop.
Quick answer
Single-threaded JS offloads async work to host APIs; when the call stack is empty the event loop moves a queued callback onto it.
In detail
There's one call stack, so only one thing runs at a time. Timers, network and I/O are handed to browser/Node APIs that do the waiting. When they finish, callbacks are queued. The event loop's rule: when the stack is empty, take the next ready callback and run it.
console.log("A");
setTimeout(() => console.log("B"), 0);
console.log("C");
// A C B — the timer waits for the stack to clearWhy interviewers ask this: The defining async question for senior front-end roles.
Common follow-up questions
- →Where do promises fit in?
This is 1 of 118+ questions in the JavaScript Interview Kit
Get every question with detailed answers, follow-ups and real code — plus coding challenges and a last-minute revision sheet. One-time payment, instant access.
⚡ Get the JavaScript Interview Kit → ₹299