Macrotask vs microtask
Both queues are first in, first out, but all microtasks drain before the next macrotask — always. A promise scheduled after a timer still runs first.
setTimeout(f, 0) is scheduled, then Promise.resolve().then(g). g runs before f.
Microtask queue
Task queue
setTimeout
Call stack