home / experts / javascript / column79 |
|
Ineritance through PrototypingThe second and more robust method to establish a class hierarchy is by creating an object of the superclass and then assign it as a Let's take the example from Page 3 and use the prototype assignment instead of these assignments inside the subClass() defintion:
Here is the new code:
Click here to invoke the following script that creates an instance of Convince yourself that you get the same results as in Page 3: bye() from subClass() and hello() from superClass().
Next: How to add properties after the object is created |
Produced by Yehuda Shiran and Tomer Shiran
All Rights Reserved. Legal Notices.
Created: March 12, 2001
Revised: March 12, 2001
URL: http://www.webreference.com/js/column79/4.html