In the previous chapter we learned how to use an object constructor:
We also learned that you can not add a new property to an existing object constructor:
To add a new property to a constructor, you must add it to the constructor function:
Dateobjects inherit from
Arrayobjects inherit from
Personobjects inherit from
Object.prototype is on the top of the prototype inheritance chain:
Array objects, and
Person objects inherit from
Sometimes you want to add new properties (or methods) to all existing objects of a given type.
Sometimes you want to add new properties (or methods) to an object constructor.
prototype property allows you to add new properties to object constructors:
prototype property also allows you to add new methods to objects constructors: