Completion requirements
View
2. JavaScript Variables
2.2. Using let
let variables are declared in a similar manner to var declared variables. When we use the let
keyword rather than var; it imposes scope constraints. The let declared variables cannot be redeclared.
This will give you a SyntaxError if you will try to do so. The scope of those variables is the block
they are defined in, also in any sub-blocks. The browser will throw a ReferenceError if you are trying
to access these variables outside of their block.
let x; // without initializing
let x = 5; // initialize with a number.