JavaScript ES6

Resources:

Shiffman - 16.1: let vs var - Topics of JavaScript/ES6
Shiffman - 16.4: for...of loop - Topics of JavaScript/ES6

let vs var

So far we have used the keyword var to declare variables. However, JavaScript version ES6 allows for a new keyword let, which we can substitute for var at any time. Try it out in the example below. The advantage of let is that it maintains a tighter scope, so that we know that our variables won't be used out of context or in ways we don't expect.