@FelixKling Okay I've created an example that makes a lot more sense to me:
`
(function() { // 1, 2, 3, 4
var foo = [];
for (let i = 0; i < 5; ++i) {
foo.push(function() {
// Outer i and this i is the same on the first iteration.
// On the next iteration they are different.
++i;
});
foo[0]();
console.log(i);
}
})();
`
(function() { // 1, 2, 3, 4, 5
for (let i = 0; i < 5;) {
// Modifies the reference.
(function() {
++i;
})();
console.log(i);
}
})();
`
My main point regarding const was that it's immutable, which is why what he was doing wouldn't work. Even if each iteration has a freshly s…