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.
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.
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.
Why Promise.then runs before setTimeout. The precise ordering rules between microtasks, macrotasks, and the rendering pipeline. The classic interview question deconstructed.
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.
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.
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.
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.
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.
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.
How to cancel async operations in JavaScript. AbortController, AbortSignal, cancelling fetch requests, building cancellable async operations, and the timeout patterns every production app needs.
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.