Error.prototype (Property)

The prototype for the Error object that can be used to extend the interface for all Error objects.

Availability:

ECMAScript edition - 3
JavaScript - 1.5
JScript - 5.0
Internet Explorer - 5.0
Netscape - 6.0
Netscape Enterprise Server - 2.0
Opera - 3.0
Property/method value type:Error object
JavaScript syntax:-Error.prototype
-myError.constructor.prototype

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:

The following methods are inherited from the Error.prototype:

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.

Example code:

   <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

Property attributes:

ReadOnly, DontDelete, DontEnum.

Cross-references:

ECMA 262 edition 3 - section - 15.11.3.1