Open Playground
JS ObjectsLesson #115

JavaScript Error Reference

JavaScript has a built in error object that provides error information when an error occurs.

The Error Object

JavaScript has a built in error object that provides error information when an error occurs.

The error object provides useful properties like name and message.

Error Object Methods & Properties

PropertyDescription
new Error()Creates a new Error object
nameSets or returns an error name
messageSets or returns an error message
causeSets or returns an error cause
Error.isError(x)Returns true if a value (x) is an Error

Error Names

Six different values can be returned by the error name property:

Error NameDescriptionTry it
EvalErrorDeprecated - use SyntaxError instead
RangeErrorA number "out of range" has occurredTry it
ReferenceErrorAn illegal reference has occurredTry it
SyntaxErrorA syntax error has occurredTry it
TypeErrorA type error has occurredTry it
URIErrorAn error in encodeURI() has occurredTry it

Non-Standard Properties and Methods > In older JavaScript code you might find non-standard properties and methods. > Do not use these properties and methods. They will not work in all browsers. > | Property | Description | > | --- | --- | > | arguments | Deprecated | > | caller | Deprecated | > | columnNumber | Firefox only | > | description | Microsoft only | > | displayName | Firefox only | > | fileName | Firefox only | > | lineNumber | Firefox only | > | number | Microsoft only | > | stack | Firefox only | > | Methods | Description | > | evalError() | Deprecated | > | internalError() | Firefox only | > | toSource() | Non Standard |

See Also: > JavaScript Errors > JavaScript Silent Errors > JavaScript Error Statements > JavaScript Debugging