destructuring: as patterns?

Brendan Eich brendan at mozilla.org
Wed Apr 18 13:59:55 PDT 2012


Herby Vojčík wrote:
>   function foo (...args) {
>     let {0:b, 0:{x,y}, foo, bar, baz} = args;
>     ...
>   }

That's not right, if you go the long way round you want:

   function foo (...args) {
     let {0:b, 0:{x,y}, 1:foo, 2:bar, 3:baz} = args;
     ...
   }

but as Allen just suggested, the right way to do it is:

   function foo ({b}, ...args) {
     let {x,y} = b;
     let [foo, bar, baz] = args;
     ...
   }


/be


More information about the es-discuss mailing list