1/13
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
|---|
No study sessions yet.
Call Stack
A stack data structure that keeps track of function execution.
Event Loop
A mechanism that checks the call stack and pushes tasks from queues when the stack is empty.
Managing asynchronous operations (like timers, API calls, user clicks) without blocking the main program flow
Macro-task queue
Queue for tasks like setTimeout, setInterval, DOM events.
Microtask Queue
Queue for Promise callbacks (.then, .catch, .finally) and queueMicrotask.
Priority: microtasks vs macrotasks
Microtasks are executed before macrotasks.
Execution order
Call stack → Microtasks → Macrotasks.
Promise
An object representing the eventual completion or failure of an asynchronous operation.
async function
A function that always returns a Promise.
await
Pauses execution of an async function until a Promise resolves or rejects.
async/await vs .then() –
async/await is syntactic sugar over Promises and makes async code easier to read.
Promise states
Pending, Fulfilled, Rejected.
Promise.all
Resolves when all Promises resolve; rejects if any Promise rejects.
Promise.allSettled
Resolves when all Promises settle, returning their outcomes.
Are Promises async by default?
Promise executor runs synchronously, but .then callbacks are async.