- default behaviour of moving all declarations to the top of the current scope before code is executed
- during the creation phase of the execution context, the javaScript engine moves variables and function defintions to the top of the script
- allows functions/vars to be used before they're declared


- reference errors vs undefined errors
→ undefined occurs when a variable is not defined, or explicitly defined as undefined
→ referenceError is thrown when trying to access a previously undeclared variable

- assignment to the variables is not hoisted, therefore it will be initialized with undefined by default.
→ behaviour is different for let and const
→ because they are in the “temporal dead zone”
→ accessing them before initialization will result in uncaught reference error
→ let and const are hoisted but not initialized with undefined

- during the complilation phase, the entire function definition including its code is hoisted to the top of the current scope

Hoisting order:
- function declarations are hoisted before variables
- this is important for understanding naming conflicts or unexpected behaviours

Index