Destructuring assignment in generator expressions and array comprehensions
- by Eli Grey
Why does for ([] in object); work fine but [void 0 for ([] in object)] or (void 0 for ([] in object)) throw a syntax error for invalid left-hand assignment?
For example, I would expect the following code to work, but it doesn't (the assertion isn't even done due to the syntax error):
let (
i = 0,
arr = [1, 2, 3, 4],
gen = (i for (i in arr) if (arr.hasOwnProperty(i))
) {
for ([] in gen) i++;
console.assertEquals([void 0 for ([] in gen)].length, i);
}