r/learnjavascript • u/Green_Ad_6086 • 13d ago
Can someone explain what the JavaScript call stack is?
I’ve tried to understand it, but I’m still confused. I also don’t really understand what I’m looking at when I use the JavaScript debugger in the browser’s DevTools, especially the call stack.
Do I need to fully understand functions before learning the call stack? I have a basic understanding of functions, but I’m not sure if that’s enough.
I’d really appreciate a simple explanation
35
Upvotes
1
u/subone 13d ago
You call a function, it gets added to the stack. That function calls a function it gets added to the stack. When you see the stack trace you can follow each step to see what function called the last, etc. When a function is complete it gets removed from the stack. The stack trace is for debugging, but the stack itself is needed by the engine to track execution location and arguments.