What happens when you run java script programm?
As you know when you run the java script program everything will happen inside the Execution Context as we discussed in the article . Java script execution is not possible without the execution context. When you run a java script program the execution context will be created. Suppose we have following line of code to execute like. var n=2; function cube(number) { var result=number*number*number; return result; } var cubeof4=cube(4); var cubeof6=cube(6); When you run this program a global execution context will be created. The execution context will be created in two phases. 1) Creation Phase Or Memory Creation Phase. 2) Code Execution Phase. What will happen in the First Phase/Creation Phase/Memory Execution Phase? In the first phase first of all java script will allocate the memory to all the variables and functions. It will allocate the memory to all the variables and allocate a special value 'undefined'. It will allocate the memory to the function 'cube'. You can ...