In JavaScript, the global execution context is the default execution context.
It is created when the JavaScript interpreter starts to run your code.
The global execution context has two properties: the global object and the this keyword.
The global object is the object that represents the window in a browser, or the global scope in Node.js.
The this keyword refers to the global object.
1)Before your javascript(.js) file run there is global execution context
that is created even file is empty.Two phase Creation phase and Execution Phase.
2)In creation phase GEC create global object and this.In browser global object
will be browser.Javascript engines allocate memory for function even before your
code run.
3)After creation phase,There is Execution phase.
sayHi() //hello
function sayHi(){
console.log("hello")
}
Javascript already know your function even before it is executed
because of hoisting as in creation phase it memorized all javascript function
declaration.
sayHi(); //error out because of sayHi is const varible not exact function.
const sayHi= function (){
console.log("hey")
}