Predicting the Execution context

So now we are coming to the end of the first section on the Object-Oriented JavaScript course.  It has been very useful to effectively take a step back and see exactly what is going on behind the curtains.  This post will wrap it up before continuing.

From the code written, here is a recap



The newSaga() function when run will create a new execution context, to make new variables which are local to that function call, so then this context will become the new current context as long as that function is running.

The var foil is not in the global scope.  The best way to see this, is if we execute the code above. What we will happen for an example in the In-memory-system is displayed as the diagram below.


So running the code we will expect the log(hero+deed+foil) to be run a total of 4 times and from the diagram of the in-memory-system we will see the following output:





Very interesting to see what is happening behind the scenes as the code is being run.

Next section will be on closures.

Leave a Reply

Your email address will not be published. Required fields are marked *