When does the event loop move a callback from the queue to the call stack?
Only when the call stack is empty. If a synchronous function is still running, queued callbacks wait, no matter how long the function takes.
Verify This Answer
Cross-check this information using these trusted sources:
More FAQs in Call Stack vs Task Queue in JavaScript
The call stack runs synchronous code immediately, one frame at a time. The task queue (macrotask queue) holds callbacks from setTimeout and events, waiting to run when the stack is empty.
The Promise callback. Promise.then callbacks go to the microtask queue, which the event loop drains completely before touching the macrotask queue where setTimeout callbacks live.
Microtasks (Promise.then, queueMicrotask) are drained completely before each macrotask and before rendering. Macrotasks (setTimeout, events) run one at a time, with microtasks drained after each.
Still have questions?
Browse all our FAQs or reach out to our support team
