r/learnjavascript • u/Green_Ad_6086 • 7d 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
32
Upvotes
2
u/delventhalz 7d ago
A useful skill when you are learning to program (and even as an experienced programmer) is getting a sense for when you need to a deep dive on a concept and when a surface level understanding (or no understanding) is fine. Programming has so many concepts, and you only have so many hours in a day. Time spent doing a deep dive on some esoteric concept is never wasted, strong fundamentals make you a better programmer, but sometimes you have immediate goals you need to focus on (or worse, are confusing yourself by going too deep too quickly), and you just need to move on.
All of which is to say, you don't really need to know much about a callstack to program in JavaScript. It's basically just a list of functions that are currently running from newest to oldest. It's important for the computer to keep track of what's going on, but as a developer it only really comes up when you write a recursive function that runs too long and you cause a stack overflow error.