We learned about the stack data structure in Chapter 4, Stacks. We will see it in action in a real application using recursion. Whenever a function is called by an algorithm, the function goes on the top of the call stack. When using recursion, each function call will be stacked on top of each other, due to the possibility of one call depending on the result of the previous invocation itself.
We can see the Call Stack in action using the browser, as demonstrated in the following screenshot:
If we execute factorial(3), open the developer tools of the browser, go to Sources, and add a breaking point in the Factorial.js file, when ...