Javascript Errors reference

Javascript build-in Error object reference.

Using Error:

Instances of Error objects are thrown as exceptions when runtime errors occur.

To create an object: new Error(message)
You uses the new keyword to create an object.
To use as a function: Error(message)
When the Errort object is used as a function the return will be an Error object as well.
message: An optional error message that provides details about the exception.

Some error types are inherited from the Error object:

EvalError: This Error type indicates that the global function eval was used in a way that is incompatible with its definition.
RangeError: This Error type indicates a numeric value has exceeded the allowable range.
ReferenceError: This Error type indicate that an invalid reference value has been detected.
SyntaxError: This Error type indicates that a parsing error has occurred.
URIError: This Error type indicates that one of the global URI handling functions was used in a way that is incompatible with its definition.
  • For alle these above Error types only the 'name' property value differ from the Error object (se reference below). For instance the 'name' property value for a SyntaxError is 'SyntaxError'.

General information about the object member types:

  1. Prototype created methods, properties or constants can only be used on instances of an object or on a primitive datatype.
  2. Constructor created methods, properties or constants can NOT be used on instances of an object or on a primitive datatype.

Prototype Methods:

Syntax: toString()
Returns an implementation defined string.

Prototype Properties:

Syntax: Error.prototype.constructor
This property of the Error.prototype holds the reference back to the Error object.
Important note: This is the same as the constructor property of an instantiated object

Constructor (Error) Properties:

Syntax: Error.constructor
The constructor property is a reference to the function that will be invoked to create a Error object.

© 2010 by Finnesand Data. All rights reserved.
This site aims to provide FREE programming training and technics.
Finnesand Data as site owner gives no warranty for the correctness in the pages or source codes.
The risk of using this web-site pages or any program codes from this website is entirely at the individual user.