This is the prototype Error object belonging to the global object and from which all Error objects are descended.
The initial value of Error.prototype is the built-in Error prototype object.
The value of the prototype property of an Error object is used to initialize child objects when that Error object is used as a constructor.
The following properties are inherited from the Error.prototype:
Error.prototype
Error.constructor
Error.name
Error.message (according to ECMA)
Error.description (according to Microsoft)
The following methods are inherited from the Error.prototype:
Error.toString()
The example demonstrates how to provide extensions to all instances of this class by adding a function to the prototype object to emulate the ECMA standard message property that is lacking in some implementations.
<HTML> <HEAD> </HEAD> <BODY> <SCRIPT> // Define a function that provides ECMA compliance function message() { return this.description; } // Register the new function Function.prototype.message = message; // Create an Error object and test the new property accessor var myError = new Error(100, "My error message"); document.write(myError.message); </SCRIPT> </BODY> </HTML>
See also: | Error(), Error(), Error.constructor, Error.toString(), prototype property |
Prev | Home | Next |
Error.number | Up | Error.toString() |
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. |