Must built-in prototypes also be valid instances? (Was: Why DataView.prototype object's [[Class]] is "Object"?)

Brendan Eich brendan at mozilla.com
Sun Sep 30 10:08:08 PDT 2012


Rick Waldron wrote:
> Using the prototype object here:
>
>>> Object.prototype.toString.call(Uint8Array.prototype).slice(8,-1))
>
> But it's really usecase dependent, sorry for the noise

It's a who-cares for sure -- typed arrays are rolling, even in IE10 
(could someone please test the above there). But implementors if not 
users, and of course the spec, must care.

js> var list = [Array, Boolean, Date, Error, Function, JSON, Math, 
Number, Object, RegExp, String]
js> for (cls of list) if ('prototype' in cls) print(cls.name, 
cls.prototype.valueOf())
Array
Boolean false
Date NaN
Error Error
Function function () {
}
Number 0
Object [object Object]
RegExp /(?:)/
String

If the way to reconcile things is to make it unobservable whether 
C.prototype is a firstborn instance of C (possibly degenerate/useless) 
or an Object with @@toStringTag and any other such symbol-named 
decorations to satisfy observable equivalence, then we should do so for 
new built-ins too, including the typed array constructors folded into 
binary data.

/be


More information about the es-discuss mailing list