JavaScript – hoisting, var, let, const
This post is a quick summary of the differences in JavaScript variable declaration.
Before ES2015 (previously named ES6), there was only one keyword to declare variables: var
. The newer standard introduced two extra useful keywords: let
and const
.
Briefly:
var
declares “almost global” variableslet
declares block variablesconst
declares block read-only variables
Explanation follows.
…