JavaScript Objects natively implement the Prototype model of Class creation. How does this basic feature of JavaScript meet the original goals of xbObject?
Methods shared via prototypes which needs construction only once.
Overridden methods from parent class available to be called
Clear inheritance chain available from instanceof
As you noted (if you have JavaScript enabled) when you loaded this page, the
initialization of the myChildClass prototype is not deferred in this most common use of
prototype based inheritance. This required that the parent class be instantiated while the
page was loading but before the DIV
used to contain messages was fully
ready.
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 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
instance of myParentClass
used as myChildClass's prototype.
Initialization of inherited immediate properties is adhoc.