We can use let statements in for loops with several variable assignments, for example:
for (let x = 0, y = 0; x < 10; ++ x);
However, we begin to get inconsistencies in implementations if we refer to one variable on another; the following results in working code in Chrome, but a ReferenceError in Firefox:
for (let x = 0, y = x; x < 10; ++ x);
Firefox doesn't seem to assign x to y after the whole expression has been parsed, and Chrome does it immediately. Note that it works in both browsers (the same statement outside the for block):
let x = 0, y = x;
The Firefox implementation seems to be wrong (especially after considering the case outside the for block), but what does the ES6 specification say about this? Is this something that should be (or has already been) communicated?
javascript firefox google-chrome ecmascript-6
varkor
source share