Page 02
Javascript
Event Loop Revision Checklist
Core idea JavaScript handles async work by coordinating the call stack, task queues, and microtask queues. Revision points Promise.then callbacks run in the microtask queue. setTim...
Core idea
JavaScript handles async work by coordinating the call stack, task queues, and microtask queues.
Revision points
Promise.thencallbacks run in the microtask queue.setTimeoutcallbacks enter the task queue.- The browser or runtime drains microtasks before moving to the next task.
console.log("start");
setTimeout(() => console.log("timeout"), 0);
Promise.resolve().then(() => console.log("promise"));
console.log("end");
Expected order: start, end, promise, timeout.