Default @@toStringTag for user classes

Andrea Giammarchi andrea.giammarchi at gmail.com
Tue Dec 2 04:15:44 PST 2014


Same question here.

AFAIK usually the `({}.toString.call(generic) === "[object Object]")` check
is the `default:` in a switch, the last `else` in a flow, etc etc ...
although I wouldn't be surprised if some code, somewhere, would do strict
comparison to know if it's a user defined object or not. In that case there
will be problems.

To be honest I also don't see much advantage in having this configurable
when `obj.constructor.displayName` or `obj.constructor.name` can be checked
instead and eventually fallback into `Object.prototype.toString.call(obj)`

This will work backward compatible too

br



On Tue, Dec 2, 2014 at 12:03 PM, Claude Pache <claude.pache at gmail.com>
wrote:

>
> Le 2 déc. 2014 à 09:04, Michał Wadas <michalwadas at gmail.com> a écrit :
>
> It probably would be backward incompatible change. Too much code depends
> on [Object Object].
>
> I'm curious to know what sort of code would be broken by
> `O.p.toString.call(x) === "[object Point]"` for instances `x` of some
> user-defined class? and whether it is not already broken by, say,
> `O.p.toString.call(new Set) === "[object Set]"`?
>
> —Claude
>
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20141202/614e5b0d/attachment.html>


More information about the es-discuss mailing list