JavaScript Error name
❮
Reference
❯
Example
Return the error name:
try {
adddlert("Welcome guest!");
}
catch(err) {
document.getElementById("demo").innerHTML = err.name;
}
Try it Yourself »
Definition and Usage
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 (ES1) feature.
ES1 (JavaScript 1997) is fully supported in all browsers:
Chrome | IE | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes | Yes |
Related Pages
JavaScript Tutorial: JavaScript Errors
JavaScript Reference: The message property
❮
Reference
❯