call stack

The region of memory where a running program keeps one frame for each function call that has started but not yet returned.

In more detail

Calling a function pushes a frame holding its local variables and where to resume; returning pops it. Recursion depth equals the number of frames stacked up, and recursion that goes too deep runs out of room and fails with a stack overflow or recursion error. An error that nothing catches unwinds the stack, and the stack trace shows the frames it passed through.

Examples

In the browser: Synchronous code runs entirely on the call stack. The event loop only starts the next microtask or task once the stack is empty, which is why a promise callback always runs after the current code finishes.
In JavaScript, microtasks and then event loop callbacks run only when the call stack is empty; an error that reaches the bottom uncaught becomes a Node.js uncaughtException.
A Python traceback lists the call stack oldest first, most recent call last.
Fiber moves React rendering off the call stack into its own linked structure so the work can pause between units.

Related terms

Taught in

References

Certification courses