What is the difference between the call stack and the 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.
Verify This Answer
Cross-check this information using these trusted sources:
More FAQs in Call Stack vs Task Queue in JavaScript
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.
Only when the call stack is empty. If a synchronous function is still running, queued callbacks wait, no matter how long the function takes.
Still have questions?
Browse all our FAQs or reach out to our support team
