prototype (Object - JavaScript)

Extends the object with additional properties and methods.

Defined in

Object (JavaScript)

Syntax

prototype.name = value
Return value Description
name The name of the property or method.
value The value of the property or method. For a property, this should be an expression. For a method, this should be a function definition.

Examples

(1) This computed label defines a property for the Object object then displays it.
Object.prototype.coname = "Acme Corporation";

var o = new Object();
o.coname
(2) This computed label defines a function for the Object object then calls it.
Object.prototype.toProper = function(o) {
	var s = new String(o);
	return s.left(1).toUpper() + s.substr(1).toLower(); 
}

var o = new Object();
o.toProper("bar")