JavaScript object prototype property
- Previous Page preventExtensions()
- Next Page seal()
- Go Up One Level JavaScript Object Reference Manual
Definition and usage
prototype
It is a global property available for all JavaScript objects.
prototype
Properties allow you to add new properties and methods to objects.
Instance
Use the prototype property to add new properties to all objects of a given type:
function employee(name, jobtitle, born) { this.name = name; this.jobtitle = jobtitle; this.born = born; } employee.prototype.salary = 2000; const fred = new employee("Fred Flintstone", "Caveman", 1970);
Syntax
object.prototype.name = value
Browser support
prototype
It is an ECMAScript1 (ES1) feature.
All modern browsers support ES1 (JavaScript 1997):
Chrome | IE | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
Chrome | IE | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support | Support |
Related Pages
- Previous Page preventExtensions()
- Next Page seal()
- Go Up One Level JavaScript Object Reference Manual