Changes

Jump to: navigation, search

JavaScript Object Basics

535 bytes added, 18:30, 26 April 2007
Extending Objects
== Extending Objects ==
 
JavaScript object instances are extremely flexible in that they can easily be extended. An object can be extended either at the point that it is instantiated with the ''new'' statement, or after it has been instantiated using the ''prototype'' mechanism.
 
=== Extending an Object at Creation ===
 
To extend an object at creation time simply pass through the extra property you wish to add as an argumen to the creation method. For example, if we wanted to a ''year'' property to our ''car'' object we copuld do so as follows:
 
<pre>

Navigation menu