What is the output?
setTimeout(() => console.log('a'), 0);
Promise.resolve().then(() => console.log('b'));
console.log('c');
- c b a
- c a b
- a b c
- b c a
Synchronous first, then the microtask queue, then the timer macrotask.
Play Problem Solving ▸
setTimeout(() => console.log('a'), 0);
Promise.resolve().then(() => console.log('b'));
console.log('c');