Configurability of @@toStringTag for Built-ins

Allen Wirfs-Brock allen at
Tue Dec 16 16:44:43 PST 2014

On Dec 16, 2014, at 4:14 PM, Brendan Eich wrote:

> It should go without saying I'm not proposing an ES6 change. This is all just es-discuss discussion, at most informative for future editions.

It would be nice if es-discuss post  were more explicits about this and discussed them as possible ES7 changes, if for no other reason than then to avoid freaking me out ;-).  There are still urgent ES6 problems the pass through here and I have to pick them out of the traffic.

> Allen Wirfs-Brock wrote:
>>> I suspect people (some of 'em;-)  will want consistent high-integrity toStringTag.
>> They can make the toStringTags they care about non-configurable at startup, at the same time they capture a reference O.p.toString.
> That's a good point. It helps one part of the equation (unreliability in face of Object.defineProperty), but of course not the other (impostor toStringTag settings on spoofing objects or mocks).

If they are specifically concerned about built-ins, almost all of them have methods that do internal brand checks and it in a number of cases those methods can be used as non-distructive tests for those built-in brands.  It would be a nice exercise for somebody to go through the built-in and identify for each of them how to perform such brand checks.

In ES6 here is no comparable reliable branding mechanism for user-defined class other than using a WeakMap/Set to register instances.


More information about the es-discuss mailing list