home / experts / javascript / column34 |
|
JavaScript lets you extend not only classes of objects, but also instances of a class. When you extend instances of a certain class, all other instances are unaffected and are not extended. This capability allows you to differentiate between instances of the same class, and practically you end up with two types of instances that inherit the properties of the main class. Let's take an example. Suppose we want to extend some instances of the
This is how you extend the string
Here is an example for using the extended
The string Notice the difference between instance extension and class extension. Class extension is done via the |
Produced by Yehuda Shiran and Tomer Shiran
Created: January 18, 1999
Revised: January 21, 1999
URL: http://www.webreference.com/js/column34/instance.html