An array destructing specification choice

Brendan Eich brendan at
Sat Nov 5 14:34:53 PDT 2011

On Nov 5, 2011, at 11:27 AM, Allen Wirfs-Brock wrote:

>> It should, as no length is assumed to mean "length === 0", IIUC, and
>> that seems so unintuitive to me that it sways my opinion towards not
>> imposing array-ness on the RHS.
> but that is exactly how it works everywhere else length is used in ES.

Who says 'length' is used by an array destructuring pattern. That should not be assumed.

> So you would be fine with the fact that
>   var r =, 1:1, length: 2, 2:2}, 0);
> produces  [0,1]
> but
>  var [...rx] = {0:0, 1:1, length: 2, 2:2};
> produces [0,1,2]

Even if Till would not (and it's clear you would not be fine with this outcome ;-), we have a choice. We can make array destructuring patterns that do not use ... ignore any RHS 'length' property. We could even forbid this kind of "row capture" -- I'm not in favor.

Row capture in object patterns requires enumeration of RHS properties. Have you worked on that case too?


More information about the es-discuss mailing list