The code above is nothing to get excited about but will serve us well to demonstrate the thread of execution.
The next question is, what happens when it steps onto this line? Where does
num get stored?
- f -above is just shorthand for the entire function.
Now comes the fun part! Actually executing our
We also create an
execution context for that function. Any variable declared in the function will be added to the function's execution context.
On the next line, we hit the
return keyword which marks the end of a function. We pop
addOne() from the
call stack and give
output a value which is
So that is it! I hope this demonstrates how our code is stepped through. This was a time-consuming article due to creating all the gifs so let me know if you like them or not. I know I only touched off the
call stack and
execution context in this article but we will be delving deeper into them in the future.
Any questions on the above, feel free to contact me on my socials! ❣️