Function.prototype

JavaScript 1.1+, ECMAScript 1.0+, JScript 1.0+ Nav3+, NES2+, IE 3+, Opera3+ Syntax

							function.prototype.property
							function.prototype.method
						

Description

The prototype property of the Function object refers to the object that serves as the prototype from which classes are created. prototype allows you to add new properties of methods to an existing class by adding them to the prototype associated with the constructor of that class.

Example

Listing 6.130 shows how the prototype property is used. The function setTask, which simply sets the "task" variable, is defined. Then a new prototype called duty is created for the String object. The duty prototype is set to call the setTask function. Now all String objects in the example ...

Get Pure JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.