es-discuss Digest, Vol 52, Issue 161

Brendan Eich brendan at mozilla.com
Tue Jun 28 17:17:57 PDT 2011


On Jun 28, 2011, at 4:22 PM, Axel Rauschmayer wrote:

>> Plus, the prototype is in some ways secondary. It's the less directly used object when one calls a constructor often, after populating the prototype. And if class methods come into the picture, the prototype is even more "backstage", an implementation detail.
> 
> 
> That seems to be a matter of taste: To me prototypes are the core of JavaScript inheritance. The single construct that is used to handle both instance-of and subclass-of. If you draw an object diagram, it is constructors that move into the background and prototypes that remain.
> 
> What do you do with constructors-as-classes to check the following?
>        o instanceof C
> You look for C.prototype in the prototype chain of o.

No, the JS engine does that!

I, or random classy-dynamic-language-experienced users, just do "o instanceof C", i.e., they ask "is o an instance of [constructed by] C"?

Not everyone mentally deconstructs operators into their more primitive semantics. Especially if there's no prototype-chain hacking, just shallow classical inheritance via a solid library.

/be



More information about the es-discuss mailing list