Difference between let and var in JavaScript
Here’s a quick and dirty illustration that helps me visualise the difference between let
(available only in ES6) and var
.
for (var i = 0; i < 5; i++) {
console.log(i); // prints 0, 1, 2, 3, 4
}
console.log(i); // prints 5…