destructuring: as patterns?

Herby Vojčík herby at
Wed Apr 18 13:52:11 PDT 2012

Brendan Eich wrote:
> Herby Vojčík wrote:
>> As was already pointed out, problems are not only _array_
>> destructurings, but more argument list destructrings, where if you
>> want to destructure 0-th argument both as b and as {x,y}, you would
>> need something like that, since you already are inside list, you
>> cannot opt for object.
> Why can't you use an object pattern? Array pattern is just shorthand for
> object pattern.

Not implicitly, not inside the argument list itself.
You would need to write

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

but between 'foo (' and ') {' you must play by the rules of array 
destructuring, where '0:' is not allowed.

> /be


More information about the es-discuss mailing list