An array destructing specification choice

Andreas Rossberg rossberg at google.com
Mon Nov 7 08:23:48 PST 2011


On 7 November 2011 17:07, Allen Wirfs-Brock <allen at wirfs-brock.com> wrote:
>>  let {x} = 666
>>
>> which will be refuted, by raising a TypeError.
>
> No,
>
> It does ToObject(666) and then looks for the "x" property of the resulting wrapper object.

Ouch, really?  I don't see that in the proposal
(http://wiki.ecmascript.org/doku.php?id=harmony:destructuring), and to
be honest, it sounds like a horrible idea.  It is just another way to
silently inject an `undefined' that is tedious to track down.  We
already have too many of those...

When would this ever be useful behaviour instead of just obfuscating bugs?

/Andreas


More information about the es-discuss mailing list