[i]Learn· Working with objects
Inheritance
All objects in JavaScript inherit from at least one other object. The object being inherited from is known as the prototype, and the inherited properties can be found in the prototype object of the constructor. See Inheritance and the prototype chain for more information.
Defining properties for all objects of one type
You can add a property to all objects created through a certain constructor using the prototype property. This defines a property that is shared by all objects of the specified type, rather than by just one instance of the object. The following code adds a color property to all objects of type Car, and then reads the property's value from an instance car1.
Car.prototype.color = "red";
console.log(car1.color); // "red"scratch
[>_]Terminal
Output appears here when you press Run.
$ ▌