home / experts / javascript / column79 |
|
Inheritance through FunctionsAlthough JavaScript does not support an explicit inheritance operator, you can implement inheritance in other ways. There are two different ways to establish a hierarchy of classes in JavaScript. The first method to create an object as a subclass of another object, is to call the superclass constructor function inside the subclass object definition. Let's look at the following example:
Click here to invoke the following assignment and function that activate these objects:
Convince yourself that it is working correctly. The methods
Let's take another example. Here is the definition of
To activate the generation of
Notice the alert boxes. They show that the Next: How to implement inheritance with prototyping |
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/3.html