Let’s take an example of the below code snippet.
EC : Execution Context
- First, a
Global Execution Contextis going to be created.
- Interpreter encounters
call x(), and again a new EC is created for x.
- Now the
ECfor x is created it will run the code line by line inside x.
- Inside x, a new function call
y()is invoked, it again creates an EC for y.
- When y is finished running, it will back to EC of
x, and variable t is assigned.
- After x run is finished, it will be back to
Global EC, and variable r is assigned.
Global ECfinishes running and the program stops.
Stay tuned — Follow me on Twitter