Hoisting reefer to the process where compiler allocate memory for variable and function before executing code.
NOTE:- Declarations that are made using var are initialized with a default value of undefined. Declarations made using let and const are not initialized as part of hoisting.
Execution Context is an abstract concept that hold information about environment within which code is being executed
Memory Part is also called as Variable Environment.
Code Part is known as Thread of Execution.
Consider a code block
Output of this code block will be
When we will run this code Global Execution Context will be created and memory will be allocated to each variable and function after that only code will be allocated.
and for function it will store entire function.
This is what happens under the hood.
that's why output will be
so this is how it works you can access these variable and method even before actually initialization in your code