Explain the JavaScript event loop, call stack, and task queues
Reported in Worldline European engineering loops. Core JavaScript concurrency model question for frontend and Node.js roles.
Interview scenario
Often asked in Worldline loops at European offices (London, Berlin, Amsterdam, Paris, Stockholm, Dublin, and remote EU). Prepare a clear spoken answer plus key trade-offs.
Model answer
Try answering aloud first
Cover trade-offs, structure, and a concrete example before revealing the baseline response.
How to frame this at Worldline: Connect your answer to measurable impact, clarity of thought, and trade-offs the team cares about. Below is a strong baseline response you can adapt with your own project examples.
JavaScript is single-threaded. The call stack runs synchronous code. Async work (timers, I/O, fetch) registers callbacks handled by Web APIs / libuv; when complete, callbacks enter task queues.
The event loop checks: if call stack empty, dequeue microtasks (Promise.then, queueMicrotask) until empty, then one macrotask (setTimeout, I/O), repeat.
Order example:
console.log("1");
setTimeout(() => console.log("2"), 0);
Promise.resolve().then(() => console.log("3"));
console.log("4");
// 1, 4, 3, 2Explain blocking vs non-blocking I/O in Node, async/await as syntactic sugar over Promises, and starvation if microtasks recurse infinitely. Starvation of macrotasks is why long Promise chains can delay setTimeout.
Discussion
Comments (0)
Share how this question came up in your loop, or add tips for others preparing.
Log in to comment on this question.