Use the prototype property to add a new property to all objects of a given type:
this.name = name;
this.jobtitle = jobtitle;
this.born = born;
employee.prototype.salary = 2000;
var fred = new employee("Fred Flintstone", "Caveman", 1970);
The value of fred.salary will be:
Try it yourself »
Definition and Usage
The prototype property allows you to add new properties and methods to existing object types.
The prototype property is supported in all major browsers.
|Return Value:||A reference to the String.prototype object|
Thank You For Helping Us!
Your message has been sent to W3Schools.