A new ES6 draft is available

Allen Wirfs-Brock allen at wirfs-brock.com
Tue Oct 1 13:40:57 PDT 2013


On Oct 1, 2013, at 1:22 PM, Claude Pache wrote:

> 
> 
>> Le 1 oct. 2013 à 19:33, Brendan Eich <brendan at mozilla.com> a écrit :
>> 
>> Allen Wirfs-Brock wrote:
>>>> Currently, that works for everything but null
>>>>> and undefined, so I assume that this pattern is used quite a bit.
>>> 
>>> Do you think it really is?
>> 
>> I don't. (That is, I don't see much x.toString() feeding into bracketed property lookup, if any.)
>> 
>> Explicit .toString() calling is rare because verbose, in addition to throwing on null and undefined. People use + ''.
> 
> I tend to use `String(x)` (which is equivalent).

Actually it isn't.  String(x) is specified to call the ToString abstract operation on x which in the current spec./proposal will throw if x is a Symbol value. 

> 
>> But that's covered, and I say if someone has a symbol named x (whether they know it's a symbol or "any") and they call .toString(), they should get what they're asking for: throw on null or undefined (or a misbehaving impl), otherwise a string.
> 
> A bit annoying that ad-hoc debugging code like `alert("got argument: " + x)` or `alert("got argument: " + String(x))` will throw for Symbols, while `alert("got argument: " + x.toString())` will throw for null and undefined, and (usually) for Object.create(null).

I suppose we could special case String(x) when x is a Symbols

Allen




More information about the es-discuss mailing list