On Monday, January 19, 2015, Brendan Eich <[email protected]> wrote:
> 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. >> > > 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. Dmitry > 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) > a > b > > But not all iterables are indexable, nor should they be. > > /be >
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

