Set.prototype.entries: indices as keys?

Brendan Eich brendan at
Mon Jan 19 11:19:11 PST 2015

Dmitry Soshnikov wrote:
>     ```js
>     let [x,y] = set; // x='a'; y='b’;
>     ```
> Would this work actually? :) Destructuring does get property, which 
> wouldn't call set's `get` method.

-- destructuring array patterns uses the iteration protocol, which is 
why the line works as Axel suggested:

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.


More information about the es-discuss mailing list