Skip to content

Comment on ES6 in Depth: Destructuringparent

Comments

I suspect it's just accessing NaN[0]. Either form of property access ([] or .) implied coercion to object (not iterable) in ES5. It makes sense that destructuring would build on that behavior.

Array destructuring doesn't use [0] access. It iterates the right-hand side. On the one hand, that means that trying to array-destructure NaN does in fact throw. On the other hand, it means you can array-destructure a generator, which is a very desirable thing to be able to do.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.