In last lecture, we learnt that a variable and a function declaration is stored in Variable object even before the execution of JavaScript code starts. During creation phase, the code is scanned for function declaration and for each function a property is created in variable object assigned with that function definition.
Similarly, code is scanned for variable declaration and for each variable, a property is created in variable object and set to undefined if the variable is created using var keyword. Otherwise, if the variable is created using let or const keyword, then it will be set to uninitialized.
Because of this, some of the variables and functions are available to use in JavaScript program before it is declared. This is called as hoisting.