JSVerse
Core JavaScript / Call Stack

The Call Stack

JavaScript tracks 'what to return to' using a stack — last one in, first one out.

The call stack is how JavaScript keeps track of where it is. Calling a function pushes a new frame on top of the stack; returning from a function pops that frame off. Because it's a stack, the most recently called function is always the first to finish — last in, first out. If functions call each other without ever returning (infinite recursion), the stack keeps growing until it overflows.

Codeeditable — Run executes your edits
Loading...
Console
Output will appear here
Visualization
Call Stack
Nothing on the stack
↑ most recent call on top
Why?

Each call adds a frame on top of the previous one. third() finishes first and pops off, then second(), then first() — the reverse order they were called in.