Skip to content

Event Loop and Async Execution Model

How JavaScript actually executes code. The call stack, task queues, microtask queue, rendering pipeline integration, and the complete execution model that governs every asynchronous operation in the browser and Node.js. You MUST understand this before diving into engine internals.

1
The Call Stack and Execution Contexts
intermediate

How JavaScript tracks function execution with a stack of frames. Execution contexts, the creation phase, stack overflow, and why understanding the call stack is prerequisite to understanding everything async.

11 min read
2
The Event Loop: Complete Model
intermediate

The full event loop algorithm that governs all async execution in the browser. Task queues, the microtask checkpoint, rendering steps, and the while(true) loop that keeps JavaScript alive.

15 min read
3
Microtasks, Macrotasks, and Rendering
intermediate

Why Promise.then runs before setTimeout. The precise ordering rules between microtasks, macrotasks, and the rendering pipeline. The classic interview question deconstructed.

14 min read
4
Microtask Starvation and Queue Priority
advanced

What happens when microtasks schedule more microtasks. Infinite microtask loops, rendering starvation, and why the microtask queue is the most dangerous queue in the browser.

11 min read
5
requestAnimationFrame and Idle Callback
intermediate

How rAF fits into the event loop, why it's not a timer, when it fires relative to rendering, and how requestIdleCallback lets you schedule non-critical work without janking the UI.

15 min read
6
Node.js Event Loop Differences
intermediate

How Node.js implements the event loop differently from the browser. Phases, process.nextTick vs queueMicrotask, setImmediate vs setTimeout(0), and the ordering gotchas that catch browser developers off guard.

14 min read
7
Promise Internals and Chaining
intermediate

How promises actually work under the hood. The state machine, reaction queues, .then() returns a NEW promise, chaining vs nesting, and the precise mechanics of promise resolution.

15 min read
8
Promise Combinators
intermediate

Promise.all, allSettled, race, and any. When to use each, how they handle errors differently, and the production patterns that make concurrent async work reliable.

14 min read
9
async/await Under the Hood
intermediate

How async/await desugars to promises and generators. Why await pauses the function but not the thread. The microtask mechanics, error handling subtleties, and common performance traps.

17 min read
10
AbortController and Cancellation
intermediate

How to cancel async operations in JavaScript. AbortController, AbortSignal, cancelling fetch requests, building cancellable async operations, and the timeout patterns every production app needs.

14 min read
11
Quiz: Predict the Event Loop Output
intermediate

7 progressively harder challenges testing your event loop mental model. Predict the console output for code mixing setTimeout, Promise.then, queueMicrotask, async/await, and process.nextTick.

12 min read