Mrs. Sari’s warung: the hearth is the call stack, the notes on the string are microtasks, the line outside is macrotasks; guess the order the dishes come out…
The key idea
Microtasks always fully drain before one macrotask
Try it in this playground
Step until the stove is empty Synchronous code runs first, until main() is done. setTimeout, then and queueMicrotask only schedule; nothing of theirs runs yet.
Watch an urgent note jump the line Once the stove is empty, every microtask runs first, even with a customer (macrotask) who queued earlier.
Notice setTimeout(0) 0 ms doesn't mean "instantly", just "as soon as possible, as a macrotask". It always loses to a waiting microtask.
Press Play, then step back Repeat until the "sync → drain micro → one macro" pattern feels automatic. That is the heart of the event loop.