Set.prototype.entries: indices as keys?
dmitry.soshnikov at gmail.com
Mon Jan 19 16:57:47 PST 2015
On Monday, January 19, 2015, Brendan Eich <brendan at mozilla.org> wrote:
> Dmitry Soshnikov wrote:
>> let [x,y] = set; // x='a'; y='b’;
>> Would this work actually? :) Destructuring does get property, which
>> wouldn't call set's `get` method.
> See http://people.mozilla.org/~jorendorff/es6-draft.html#sec-
> runtime-semantics-destructuringassignmentevaluation -- destructuring
> array patterns uses the iteration protocol, which is why the line works as
> Axel suggested:
Ah, I see, that's great! Thanks for clarification.
> js> let set = new Set(['a', 'b']);
> js> let [x,y] = set;
> js> console.log(x, y)
> a b
> js> for (let elt of set) console.log(elt)
> But not all iterables are indexable, nor should they be.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss