1.When js code runs it create global execution context.
2.Execution context consist of two part 1) Memmory 2) Code
3.Execition context created in two phases
1) Creation phase also known as the Memory creation phase.
2)Second will be the code exection tion phase.
In First Phase
Js allocation memory to all the variables and functions.
Note: one thimg is here to note js only allocation memory to variables and functions,Not data,values assigned to thes variables.
n : undefined
square:{ whole code}
total : undefined
(values will be assign in second code execution phase)
In Second Phase
js read all code line by line.
and assign value to the variables.
function invocation:Method which call the function for exection called invocation function.
Note: When we invoke a function than brand new execution context is created in the code phase which exectly have save two parts 1)Memory 2) Code.
After the execution ,code complete execution the global context finish at any level.
Call statck maintain the order od execution on execution context.
Comments
Post a Comment