Hoisting is Dead: var vs. let vs. const
Reminder
Global variables 🤮
Use strict 😅
Hoisting
Variable hoisting
Function hoisting
A little bit better
let
Variables are only accessible after their declaration.
Variables are only accessible in the bloc where they are declared.
const
const
variables cannot be reinitialized.
const
does not mean immutable.
It is recommended to declare all variables as const
except if reusing the variable is inevitable.
This is less error-prone and avoids some common inattention mistakes.
const
usage avoids clumsy variable reuse:
Last updated