Advertisement
Beginner JavaScript, Event Loop & Concurrency

What is the call stack?

Short answer

The call stack tracks which function is currently executing and what called it, growing with each function call and shrinking as functions return — a 'stack overflow' happens when it grows too deep, usually from unbounded recursion.

Save JavaScript mock interview
Advertisement
AModel answer
The call stack tracks which function is currently executing and what called it, growing with each function call and shrinking as functions return — a 'stack overflow' happens when it grows too deep, usually from unbounded recursion.
function a() { b(); }
function b() { c(); }
function c() { console.log('deepest'); }
a(); // stack: a -> b -> c, then unwinds
Real-world example
Reading a stack trace in an error to see the exact chain of function calls that led to a crash.
Likely follow-ups
  • What causes a 'Maximum call stack size exceeded' error?
Related topics