Hint
Synchronous → Microtasks (all) → Next Macrotask
JS is single-threaded. The call stack runs sync code. Async callbacks go into task queues. The event loop picks tasks when the stack is empty.
Microtasks (Promises, queueMicrotask) drain completely after each task before the next macrotask runs.
console.log('1');
setTimeout(() => console.log('2'), 0); // macrotask
Promise.resolve().then(() => console.log('3')); // microtask
console.log('4');
// Output: 1 → 4 → 3 → 2