Standard builtins' prototypes and toString

C. Scott Ananian ecmascript at
Thu Jun 12 11:29:15 PDT 2014

On Thu, Jun 12, 2014 at 12:59 PM, Allen Wirfs-Brock
<allen at> wrote:
> So, I think the current spec. best matches our consensus about changing
> these prototypes to non-consructor instances.  I think my proposed
> alternative toString fall back pattern is more useful, but is a bigger
> breaking change. Are we willing to up the bet, or should we let it ride as
> is?

Just restating and naming the alternatives:

(a) `#toString` throws TypeError when given a non-instance.  Changes
`Date#toString()`, no change to `{})`.

(b) `#toString` is generic; invokes `Object#toString` when given a
non-instance.  Changes both `Date#toString()` and

(c) `#toString` is generic; uses a "zero" value when given a
non-instance.  No change to `Date#toString()`; changes

(d) `#toString` returns a "zero" value when given a prototype, throws
TypeError otherwise. No change to `Date#toString()` or

Option (a) is what is in the current spec.
Options (b) and (c) make the `toString` method generic.
Option (d) preserves compatibility to the greatest degree possible.

ps. I prefer (a).

More information about the es-discuss mailing list