Description

let allows you to declare variables, limiting its scope to the block, statement, or expression on which is used. This is unlike the var keyword, which defines a variable globally, or local to an entire function regardless of block scope.

Examples

A let expression limit the scope of the variable declared only in that expression.

var a = 5;
let(a = 6) alert(a); // 6
alert(a); // 5

Used inside a block, let limits the variable's scope to that block. Note the difference between var which its scope is inside the function where is declared