Adding Properties and Methods to Objects
This section provides a quick description of adding properties and methods to objects only. A tutorial example is provided on adding 1 extra property and 1 extra method to 1 object only.
After an object has been created from the constructor function, additional properties and methods can be added to this object only, using these formats:
object_name.property_name = initial_value; object_name.method_name = function_name;
Here is tutorial example that creates two objects from "Book()", and adds 1 extra property and 1 extra method to object "myBook" only:
The output of the tutorial example shows that properties defined in the constructor function are added to both objects. But properties and methods added to object "myBook" are for "myBook" only.
Table of Contents