Event Loop & Task vs Microtask Basics
See how the event loop runs sync code first, then microtasks, then tasks. Practice with setTimeout, Promise.then, and queueMicrotask.
Intro to event loop
Goal: Learn the basic order: sync code → microtasks (Promise/queueMicrotask) → tasks (setTimeout).
- Sync first
- Microtasks next
- Tasks last

Sync first
Synchronous statements execute top-to-bottom before any queued callbacks.
// Sync code runs immediately
console.log("A: sync start");
console.log("B: sync middle");
console.log("C: sync end");

All lessons in this course
- Event Loop & Task vs Microtask Basics
- Promises — States, Chaining, Error Handling
- Promise.all / any / race / allSettled — choose the right tool