prototype Property

By: Dusty Arlia
Published on Saturday, June 8, 2013, 09:11 PM
Last Updated on Tuesday, July 14, 2015 at 2:08 PM
Total Updates: 5

All JavaScript objects have an associated prototype attribute. The prototype attribute specifies the object from which it inherits properties.

Objects created by using object literals use Object.prototype as their prototype. Objects created with the new operator use the value of the prototype property of their constructor. Objects created with Object.create() use the first argument to that function (which may be null) as their prototype.

You can get the prototype of any object by passing that object to Object.getPrototypeOf()

The prototype property allows you to add properties and methods to an object. The prototype attribute is useful for making a "base class" object of certain functions.

Here is the basic syntax:

[object name].prototype.[new property name]=[value];

Comments:

Ad: