Creation Phase & Execution Phase in JavaScript
Now Let's explore how an execution context is created by the JavaScript engine, which we have seen in the previous article, and how the JavaScript engine controls the execution context.
In this article, we will learn what is creation phase and execution phase in javascript.
Basically, the Execution context has two pahses:1) Creation phase and 2) Execution phase
1) Creation phase :
For Each Function(function Declaration) property is created in the variable object, which is pointing to that function.
For each variable(Variable Declaration) property is created in the variable Object, Which is then set to undefined
Arguments Objects are created that were passed into the function
In other words this process is also called Hoisting.
Hoisting is a javascript mechanism where variables and function declarations are moved to the top of their scope before the code execution.
2) Execution phase:
Current Execution context run line by line.