Event Loop

Microtask queue

A higher-priority queue for promise callbacks and queueMicrotask. It's drained completely — every microtask runs — before the next macrotask or a render.

Two .then() callbacks both run before the next setTimeout gets a turn.

Microtask queue
.then #1
.then #2
Task queue
setTimeout
Call stack
Both .then() run before the timer gets a turn

One of 40 cards in the JavaScript deck. Browse every card.