Block-scoped variables in loops must always be initialized when lowered to var
This code will currently change meaning:
for (let i = 0; i < 10; i++) {
let something
if (i % 2) something = true
console.log(something)
}
Because the resulting var something
will carry over its value in subsequent iterations, whereas the let
variable is reset to undefined on every iteration.
I guess this can be solved by always adding an initializer when inside of a loop.