Hoisting
Essentially gives the impression variables exist even before declaration.
- Variables declared with
varare hoisted to the top of their function scope, but their initialization remains where the code originally places it. Before initialization, the variable isundefined. - Variables declared with
letandconstare also hoisted to the top of their block, but they are not initialized. Accessing them before declaration results in aReferenceError.