let
var foo = 123;
if (true) {
var foo = 456;
}
console.log(foo); // 456let foo = 123;
if (true) {
let foo = 456;
}
console.log(foo); // 123var index = 0;
var array = [1, 2, 3];
for (let index = 0; index < array.length; index++) {
console.log(array[index]);
}
console.log(index); // 0Functions create a new scope
Generated JS
Switch
let in closures
Summary
Last updated