What is a call stack?
3 May 2022 (Updated 5 May 2022)
In a nutshell
A call stack is a stack data structure that keeps track of function execution within a program.
When a function is invoked, it gets pushed onto the stack. When it returns, it’s popped off the stack. Here’s a visualization of how a call stack works:

Many programming languages print the call stack when an exception occurs to help you debug issues.
Debugging tools like the Chrome DevTools debugger or PHP’s Xdebug also let you inspect the call stack at any given breakpoint. This can be invaluable in many cases (e.g., you want to understand why your code unexpectedly reaches a particular execution path).
Tagged:
Computing
References (10)
Posts that link to this one.
- Callback queue
- Chrome DevTools debugging tips
- Debugging: What is step out?
- How web browsers process asynchronous code
- JavaScript engine vs JavaScript environment
- JavaScript event loop
- The JavaScript environment
- What does it mean to say JavaScript is single-threaded?
- What is a debugger?
- What is a thread?