setTimeout(fn, 0)
0 ms is a minimum delay, not 'run now'. The callback still waits for the stack to clear and all microtasks to drain first — so it runs last, not immediately.
console.log order: 'A' (sync), 'B' (promise), 'C' (setTimeout 0) — C is last.
log('A')
setTimeout(() => log('C'), 0)
Promise.resolve().then(() => log('B'))
out
Async
Bpromise
Ctimeout 0
Tap the example to replay it · press and hold to slow it down