An array destructing specification choice

Andreas Rossberg rossberg at
Mon Nov 7 09:21:53 PST 2011

On 7 November 2011 17:34, Allen Wirfs-Brock <allen at> wrote:
>>  It is just another way to
>> silently inject an `undefined' that is tedious to track down.  We
>> already have too many of those...
> It is how the language currently behaves in all situations where an object is needed but a primitive values is provided.
> We want consistency in language design, not a hodgepodge of special cases and different rules.

Hm, I don't quite buy that. There are plenty of places in ES today
where we don't convert but throw, e.g. "in", "instanceof", various
methods of Object, etc.  Destructuring arguably is closely related to
operators like "in".  Implicit conversion would violate the principle
of least surprise for either, IMHO.

I agree that consistency is a nice goal, but it seems like that train
is long gone for ES. Also, if consistency implies proliferating an
existing design mistake then I'm not sure it should have the highest

>> When would this ever be useful behaviour instead of just obfuscating bugs?
> let {toFixed, toExponential} = 42;

OK, I guess "useful" is a flexible term. Would you recommend using
that style as a feature?


More information about the es-discuss mailing list