An array destructing specification choice

Allen Wirfs-Brock allen at wirfs-brock.com
Sat Nov 5 11:16:45 PDT 2011


On Nov 5, 2011, at 11:01 AM, John J Barton wrote:
>> 
> 
> I can see why my version is wrong: I am interpreting square brackets
> on the RHS like JS devs would.
>  let z = _rhs[0]; // LHS was array, so get zeroth elt,but RHS is
> object so property access.
> 
> But the feature does not do this. Rather, since LHS is array, it
> coerces the RHS to an array:
>  let z = coerceToArray(_rhs)[0];
> and we don't know what that operation means.


What do you think this returns:

    Array.prototype.pop.call({0:0, 1:1, length: 2, 2:2})

allen


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20111105/0c2f6873/attachment-0001.html>


More information about the es-discuss mailing list