- The call stack works based on the LIFO principle, i.e., last-in-first-out.
- When you execute a script, the JavaScript engine creates a global execution context and pushes it on top of the call stack.
- Whenever a function is called, the JavaScript engine creates a function execution context for the function, pushes it on top of the call stack, and starts executing the function.
- When the current function completes, the JavaScript engine pops it off the call stack and resumes the execution where it left off.
- The script will stop when the call stack is empty.

-
Stack overflow
- The call stack has a fixed size, depending on the implementation of the host environment, either the web browser or Node.js.
- If the number of execution contexts exceeds the size of the stack, a stack overflow error will occur.