JavaScript Error name
Example
Return the error name:
try {
adddlert("Welcome guest!");
}
catch(err) {
document.getElementById("demo").innerHTML = err.name;
}
Try it Yourself »
Description
The name property sets or returns the name of an error.
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 | 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 » |
Syntax
errorObj.name
Return Value
| Type | Description |
| A string | The name of the error. |
See Also:
Browser Support
error.name is an ECMAScript1 (JavaScript 1997) feature.
It is supported in all browsers:
| Chrome | Edge | Firefox | Safari | Opera |