Macrotask vs Microtask
All microtasks drain before the next macrotask — always. A promise scheduled after a timer still runs first, because microtasks jump the queue.
setTimeout(f, 0) is scheduled, then Promise.resolve().then(g). g runs before f.
Microtask Q
Task Queue
setTimeout
Call Stack
Tap the example to replay it · press and hold to slow it down