0Pricing
Frontend Academy · Lesson

The Event Loop: Call Stack Queue Microtasks

Visualize how JavaScript executes: the call stack, the task queue, microtasks from Promises, and why the UI never blocks during async operations.

JavaScript Is Single-Threaded

JavaScript runs on a single thread — it can only execute one piece of code at a time. Yet it handles thousands of async operations (network requests, timers, UI events) without blocking. How? The event loop.

The Call Stack

The call stack is where JavaScript keeps track of which function is currently running. When a function is called, a frame is pushed. When it returns, the frame is popped. If the stack is full (infinite recursion), you get a stack overflow.

function c() { /* does something */ }
function b() { c(); }
function a() { b(); }
a();

// Call stack during c():
// c    ← top
// b
// a
// (anonymous)

All lessons in this course

  1. The Event Loop: Call Stack Queue Microtasks
  2. Callbacks and Callback Hell
  3. Promises: then catch finally Promise.all
  4. async/await and Error Handling
← Back to Frontend Academy