Creation Phase a.k.a. Global Execution Context
When running code at the base level the JS engine will automattically do the following:
Creates a global object. Your code will sit inside of this global object.
Creates a special variable called, "this". At the global level, "this" would equal the Global (window) Object.
A reference or link to the outer environment if there is one.
Hoisting, which setups up functions and creates a list of variables (but sets them all to"undefined"). Example code is below.
Then JS will run your code line by line (which includes adding values to variables, thusreplacing the "undefined".