You can create several objects and make them share a common ancestor. In a class-based object oriented world, this would be called sub-classing. Instantiating each one means it would inherit properties from its super-class, but objects of the same class in a real object oriented system do not share property values unless the static (class) factory method that instantiates them presets the same values as they are initialized.
In JavaScript, because the prototype chain is used to inherit properties from parent objects and not parent classes, then objects will inherit property values unless they override them locally.
If you are used to the class-based object oriented way of doing things, this can be quite distracting.
Prev | Home | Next |
Shallow copying | Up | Shell Scripting with JavaScript |
JavaScript Programmer's Reference, Cliff Wootton Wrox Press (www.wrox.com) Join the Wrox JavaScript forum at p2p.wrox.com Please report problems to support@wrox.com © 2001 Wrox Press. All Rights Reserved. Terms and conditions. |