Local Scope

carName is undefined outside myFunction():

Global Variable

GLOBAL variable can be accessed from any script or function.

Global Variable

assign a value to a variable that has not been declared, it will automatically become a GLOBAL variable:

HTML global variables with var

HTML, global variables defined with var, will become window variables.

HTML global variables with let

HTML, global variables defined with let, will not become window variables.