1 min read
Default Execution Context is always Global Context.
The Global Execution Context is for variables and functions that are not inside of any function.
Execution Context Stack (ECS):
It's a stack of Execution Context. ( Last In First Out ) to store all the execution stacks created during the life cycle of the script.
Global Execution Context is present by default at the bottom of the Execution Context Stack.
While executing the global execution context code.
Each function gets its own execution context & pushed to the top of the execution context stack.
JS engine executes the function whose execution context is at the top of the execution context stack.
Once all the code of the function is executed, JS engines pop out that function’s execution context and start’s executing the function which is below it.