A new ES6 draft is available

Claude Pache claude.pache at gmail.com
Tue Oct 1 13:22:50 PDT 2013



> 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).
 
> 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).

—Claude

> 
> /be
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss


More information about the es-discuss mailing list