JavaScript Recursion Visualization
Some deeper analysis of recursion in JavaScript for a better understanding.
We'll cover the following...
Background
We just saw a lot of function invocations. Go ahead and look at the cost of function invocation. Every function invocation is costly for a program. In the example of recursive functions, we can use neater code, but it comes at a cost. Let’s take a look at it in greater detail.
Introduction to call stack
All programs maintain a “call stack” where every invocation of a function pushes them onto the stack and then removes them when the function returns. Every function invocation adds an ...