The call stack tracks the order of function execution in JavaScript. It works on a Last In, First Out (LIFO) principle. When a function is invoked, it is added to the top of the call stack, and once it finishes execution, it is removed from the call stack. If a function calls another function, the called function is added to the top of the call stack, creating a hierarchy of execution.
Consider the following code:
Let us see a step-by-step visualization of the call stack during the above code's execution.