Standard builtins' prototypes and toString

Till Schneidereit till at tillschneidereit.net
Thu Jun 12 09:19:23 PDT 2014


On Thu, Jun 12, 2014 at 6:03 PM, C. Scott Ananian <ecmascript at cscott.net>
wrote:

> FWIW, in Chrome 36:
>
> ```javascript
> > Date.prototype.toString()
> "Invalid Date"
> > ({ toString: Date.prototype.toString }).toString()
> TypeError: this is not a Date object.
> > Number.prototype.toString()
> "0"
> > String.prototype.toString()
> ""
> > Boolean.prototype.toString()
> "false"
> > RegExp.prototype.toString()
> "/(?:)/"
> ```
>

Yes, that's how it's supposed to work according to ES5, and does in all
engines. Annex E.1 of ES6 notes that this changes.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140612/e05fa9e9/attachment.html>


More information about the es-discuss mailing list