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
| Property | Description |
|---|---|
| new Error() | Creates a new Error object |
| name | Sets or returns an error name |
| message | Sets or returns an error message |
| cause | Sets 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 Name | Description | Try it |
|---|---|---|
| EvalError | Deprecated - use SyntaxError instead | |
| RangeError | A number "out of range" has occurred | |
| ReferenceError | An illegal reference has occurred | |
| SyntaxError | A syntax error has occurred | |
| TypeError | A type error has occurred | |
| URIError | An error in encodeURI() has occurred |
Warning: 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. PropertyDescription argumentsDeprecated callerDeprecated columnNumberFirefox only descriptionMicrosoft only displayNameFirefox only fileNameFirefox only lineNumberFirefox only numberMicrosoft only stackFirefox only MethodsDescription evalError()Deprecated internalError()Firefox only toSource()Non Standard
Note: See Also: JavaScript Errors JavaScript Silent Errors JavaScript Error Statemets JavaScript Debugging