agentmentoragentmentor

Glossary

12 terms from "JavaScript async/await: Why Your console.logs Print in the "Wrong" Order." Look them up when you get stuck; the first mention in the text carries a hover definition.

TermDefinitionSource
call stackThe last-in-first-out list of functions JavaScript is currently running; calling a function pushes a frame on, returning pops it off.MDN: JavaScript execution model
single-threadedJavaScript runs on one thread, so it does exactly one thing at a time and cannot run two pieces of code in parallel.MDN: JavaScript execution model
run-to-completionThe rule that each job runs completely before any other job starts, so synchronous code always finishes before a deferred callback runs.MDN: JavaScript execution model
event loopThe mechanism that watches the call stack and, when it is empty, pulls the next callback from the queues to run.MDN: JavaScript execution model
task queueThe first-in-first-out queue (also called the callback or macrotask queue) where deferred callbacks such as setTimeout's wait to run.MDN: JavaScript execution model
task (macrotask)A unit of work the event loop runs one at a time from the task queue, such as a setTimeout callback or an event handler.MDN: JavaScript execution model
microtaskA short callback that runs after the current code finishes and the stack is empty, but before the next task; promise callbacks are microtasks.MDN: Using microtasks in JavaScript with queueMicrotask()
microtask queueA separate, higher-priority queue that is drained completely before the event loop runs the next task; formally it is not a task queue.HTML Living Standard: Event loops
setTimeoutA function that schedules a callback to run after a delay; a delay of 0 runs it in a later event-loop pass, not immediately.MDN: setTimeout()
Promise.prototype.then()A method that schedules a callback (as a microtask) for when a promise settles and returns a new promise; the callback always runs asynchronously.MDN: Promise.prototype.then()
async functionA function that runs synchronously up to its first await and returns a promise; with an await inside, it always completes asynchronously.MDN: async function
awaitAn operator that pauses only its own async function until a promise settles, returns control to the caller, and resumes the rest as a microtask.MDN: await