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 » |
See Also:
The message property of the Error object.
Syntax
errorObj.name
Return Value
Type | Description |
A string | The name of the error. |
Browser Support
error.name
is an ECMAScript1 (JavaScriopt 1997) feature.
It is supported in all browsers:
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | Yes |
Related Pages
JavaScript Tutorial: JavaScript Errors
JavaScript Reference: The message property