If xbObject uses deferred prototype construction, why does deferred prototype construction work in xbObect but not in the previous example?
xbObject does not replace the entire prototype but instead adds references to individual properties of the prototype.
Easy inherited intialization
Easy to call overridden methods from parent class
Prototype construction is delayed until the first instance of a class is created.
Inheritance chain not available from instanceof
Initialization of prototype from a parent class can lead to dependencies in the child class on the arguments used to construct the parent class instance used as a prototype. For example, an immediate property in the parent class which becomes a prototype property in the child class.
As you can see in the example, the
name property of
myChildClass was prototyped to the value defined in the call to create the
myParentClass used as myChildClass's prototype.