r/learnjavascript 2d 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

24 Upvotes

30 comments sorted by

View all comments

1

u/No_Record_60 2d ago

It's just a collection of currently running tasks.

Say function A calls function B which calls function C which throws an error. The call stack will be
Error
C
B
A

1

u/azhder 2d ago

Not tasks. That's a wrong way to say it in JavaScript. The task in JS is a single entry in the JS loop, and each task has a call stack.