The initial value of the prototype property of an Object object is the built in Object prototype object.
Object objects inherit the following properties from the Object.prototype:
Object.constructor
Object.prototype
Object objects inherit the following methods from their prototype:
Object.toString()
Object.valueOf()
The prototype property for the Object prototype object is null.
The example demonstrates how to provide extensions to all instances of this class by adding a function to the prototype object.
<HTML> <HEAD> </HEAD> <BODY> <SCRIPT> // Define a function that extends the output capabilities of Object objects function init() { this.width = 100; this.height = 200; this.depth = 300; return ""; } // Register the new function Object.prototype.init = init; // Create a new object myObject = new Object(); myObject.init(); document.write(myObject.width + "<BR>"); document.write(myObject.height + "<BR>"); document.write(myObject.depth + "<BR>"); </SCRIPT> </BODY> </HTML>
ECMA 262 edition 2 - section - 15.2.3.1
ECMA 262 edition 2 - section - 15.2.4
ECMA 262 edition 3 - section - 15.2.3.1
Prev | Home | Next |
Object.propertyIsEnumerable() | Up | Object.toLocaleString() |
JavaScript Programmer's Reference, Cliff Wootton Wrox Press (www.wrox.com) Join the Wrox JavaScript forum at p2p.wrox.com Please report problems to support@wrox.com © 2001 Wrox Press. All Rights Reserved. Terms and conditions. |