Event Loop
Event Loop — The event loop is JavaScript's mechanism for handling asynchronous operations by managing the call stack, task queues, and microtask queue. JavaScript is single-threaded but can handle async operations through the event loop. The call stack executes synchronous code. Async callbacks (from setTimeout, promises, etc.) are placed in queues. The event loop continuously checks if the call stack is empty, then moves tasks from the queues to the stack. Microtasks (promises) have higher priority than macrotasks (setTimeout, DOM events). This term relates to the Promise category of the reference. You will meet event loop in practice when working with APIs such as Promise.prototype.then(), Promise.prototype.catch(), Promise.prototype.finally(), Promise.resolve(). Related terms: Closure, Hoisting, Prototype Chain, Temporal Dead Zone (TDZ), IIFE (Immediately Invoked Function Expression), Currying. Understanding event loop makes the rest of the JavaScript documentation noticeably easier to follow, because the concept recurs across methods, guides, and error messages.