FlashcardAdvanced

Microtasks run before setTimeout callbacks

Promise callbacks and other microtasks always run before timer callbacks like setTimeout, even with a zero delay.

Question

Why does a Promise .then() run before a setTimeout(fn, 0)?

Click to reveal answer