Standard builtins' prototypes and toString

Till Schneidereit till at
Thu Jun 12 05:26:49 PDT 2014

While working on changing Date.prototype to be a plain object in
SpiderMonkey, we realized that there's an issue: the way things are specced
now, `alert(Date.prototype)` will throw, because `Date.prototype.toString`
isn't generic. The same applies for all builtins with non-generic
`toString` prototype functions.

To resolve this, I propose changing these `toString` to first check if the
`this` value is %FooPrototype% (e.g., %DatePrototype% in the case at hand)
and return the result of the equivalent of calling the original

I'm not sure if that is enough to cover subclasses of these builtins. Will
calling `toString` on the prototype of `class MyDate extends Date{}` still
throw? If so, that would at least not be a backwards-compatibility concern,
but it's probably also not desirable.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list