Frontend & browser·JavaScript in the browser
the promise callback ran before the timeout you scheduled first, and before the browser painted anything.
Microtask
Also calledmicrotask queue, promise job
A callback queued by a resolved promise, `queueMicrotask` or a mutation observer, which runs after the current task and before the browser gets a chance to render. The entire microtask queue is drained each time, including microtasks queued by microtasks, so a promise chain that keeps resolving can starve rendering indefinitely. That ordering — all microtasks, then render, then the next task — is the actual answer to why promise callbacks beat timers.