Chapter 01 · One thread01 / 19
One thread, one call stack
JavaScript runs your code on a single thread: one worker, doing one thing at a time. To remember where it is, it keeps a call stack.
Calling a function pushes a frame onto the stack. Returning pops it off. The top frame is the code running right now. Every frame below it is paused, waiting for the call above it to return.
Watch main() call greet(), wait for its answer, then call console.log(). When the stack is empty again, the script is done.
Step through it
Pause and move one step at a time, like a debugger.
Uncaught Error: out of greetingsat greet (greet.js:2:9)at main (greet.js:5:15)at greet.js:8:1
A stack trace is a snapshot of the call stack at the moment of an error: the top frame first, down to the script that started it all.