Destructuring assignment problem
Posted
by Eli Grey
on Stack Overflow
See other posts from Stack Overflow
or by Eli Grey
Published on 2010-03-25T23:36:12Z
Indexed on
2010/03/25
23:43 UTC
Read the original article
Hit count: 408
JavaScript
Why does for ([] in iterable);
work fine but [void 0 for ([] in iterable)]
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, iterable = (i for (i in [1, 2, 3, 4]))) {
for ([] in iterable) i++;
console.assertNotGreater([void 0 for ([] in iterable)].length, i);
}
© Stack Overflow or respective owner