@@toStringTag spoofing for null and undefined

Claude Pache claude.pache at gmail.com
Tue Feb 10 00:54:03 PST 2015

> Le 10 févr. 2015 à 06:40, Gary Guo <nbdd0121 at hotmail.com> a écrit :
> Sorry for not noticing the change. It seems the ES6 spec changes the behavior of *.prototype object. In ES5, *.prototype is itself a * object. However, because in ES5 Object.prototype.toString.call(String.prototype) will return [object String], my proposal does not break any legacy code, instead, if not implemented, legacy code could be broken.

Changing `String.prototype` from String to non-String is indeed a risk by itself. But the issue I was mentioning is independent of that, namely that an unknown object would be misidentified as String and would throw on methods that work only on Strings, e.g.: `if (getType(obj) == "String") { return obj.toUpperCase() }`, where `getType()` is based on `O.p.toString`.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150210/e4cefe74/attachment.html>

More information about the es-discuss mailing list