Easy Tutorial
❮ Prop Month Value Prop Style Display ❯

JavaScript prototype Property

JavaScript String Object


Definition and Usage

The prototype property allows you to add properties and methods to objects.

Note: Prototype is a global property applicable to all JavaScript objects.

Syntax


Browser Support

All major browsers support the prototype property.


Example

Using the prototype property to add a property to an object:

function employee(name, jobtitle, born) {
    this.name = name;
    this.jobtitle = jobtitle;
    this.born = born;
}
var fred = new employee("Fred Flintstone", "Caveman", 1970);
employee.prototype.salary = null;
fred.salary = 20000;
document.write(fred.salary);

The above example outputs:

20000

JavaScript String Object

❮ Prop Month Value Prop Style Display ❯