> But before you've created an instance, it is pretty handy to have the > constructor bound to a name so you can get to it. I don't think making the > named object be the constructor means that they're *more* important, just > that you generally have to go through them *first* to get to an instance. > They get the name because they're the entrypoint.
It depends on how you view instance creation: Prototypes-as-classes: new C() means: (1) Create an instance o whose prototype is C. (2) Initialize the new instance via o.constructor(). Constructor functions: new C() means: (1) Create an instance o whose prototype is C.prototype. (2) Initialize it via the body of the constructor function (with |this| set up properly). Thus: - Prototypes-as-classes: step (1) determines the name of the class (which – to me – makes more sense for instanceof and subclassing) - Constructor functions: step (2) determines the name of the class. -- Dr. Axel Rauschmayer [email protected] twitter.com/rauschma home: rauschma.de blog: 2ality.com _______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

