JavaScript Error Reference
New to JavaScript Errors?
Error Object Methods & Properties
| Name | Description |
|---|---|
| new Error() | Creates a new Error object |
| cause | Sets or returns an error cause |
| name | Sets or returns an error name |
| message | Sets or returns an error message |
| Error.isError(x) | Returns true if a value (x) is an Error |
Error Names
| Error Name | Description | Try it |
|---|---|---|
| EvalError | Deprecated - use SyntaxError instead | |
| RangeError | A number "out of range" has occurred | Try it » |
| ReferenceError | An illegal reference has occurred | Try it » |
| SyntaxError | A syntax error has occurred | Try it » |
| TypeError | A type error has occurred | Try it » |
| URIError | An error in encodeURI() has occurred | Try it » |
The Error Object
The Error object is a built-in JavaScript object.
Error objects are normally created automatically when JavaScript throws an error.
You can also create your own error object with the new Error() constructor.
Example
const err = new Error("Something went wrong");
(err.name); // Error
(err.message); // Something went wrong
Try it Yourself »
Built-in error types inherit from Error.
ErrorRangeErrorReferenceErrorSyntaxErrorTypeErrorURIErrorEvalError(deprecated)AggregateError
Example
const err = new TypeError("Expected a number");
(err instanceof TypeError); // true
(err instanceof Error); // true
Try it Yourself »
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 |