Call stack, microtasks vs macrotasks, ordering rules, and how to predict execution order in any interview question.
Preview — first 3 of 103 cards
What is the call stack?
A LIFO stack of execution contexts. Every function call pushes a frame; return pops it. JS has a single stack, so only one piece of code runs at any instant.
function a(){ b(); }
function b(){ c(); }
function c(){ throw new Error('boom'); }
a();
// stack trace: c -> b -> a -> global
Execution context
Each frame holds its variables, `this`, and scope chain. Contexts: global, function, and (rarely) eval. The stack is just a list of these contexts.
function f(x){
const y = x + 1;
return y;
}
// frame: { x, y, this, scope }
Stack overflow
Deep or infinite recursion exceeds the engine's max stack size and throws RangeError: Maximum call stack size exceeded. Engines do not generally do tail-call optimization, with one notable exception: Safari/JavaScriptCore implements proper tail calls (ES2015).
function boom(){ boom(); }
boom(); // RangeError: Maximum call stack size exceeded
100 more cards in this sheet
Unlock the Languages bundle — ₹399
One-time payment. Unlocks this sheet and 7 other sheets in the bundle, plus a typeset PDF of each.
Unlock the bundle
See all bundles
Or get all 76 sheets for ₹999 — one payment, every future sheet included.