Microtask and Macrotask Queues
Microtask & Macrotask Queues
Section titled “Microtask & Macrotask Queues”Introduction
Section titled “Introduction”JavaScript has two task queues: microtasks (high priority) and macrotasks (lower priority). The event loop processes all microtasks before moving to the next macrotask.
Topics Covered
Section titled “Topics Covered”- What Goes Where — Which operations go in which queue
- Execution Order — How the event loop prioritizes queues
- Starvation — When microtasks prevent macrotasks from running
Summary
Section titled “Summary”Microtasks run before the next macrotask. Microtask queue is fully cleared each cycle. Promise callbacks are microtasks.