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...

Intermediate17 Apr 2026#javascript#async#runtime

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.
  • setTimeout callbacks 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.