JavaScript Error name Property
❮
Reference
❯
Example
Return the error name (we have written "alert" as "adddlert" to deliberately produce an error):
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 | An error has occurred in the eval() function. Note: Newer versions of JavaScript does not throw any EvalError. 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 » |
Tip: Also see the message property of the Error object.
Browser Support
Property | |||||
---|---|---|---|---|---|
name | Yes | Yes | Yes | Yes | Yes |
Syntax
errorObj.name
Technical Details
Return Value: | A String, representing the name of the error |
---|---|
JavaScript Version: | 1.0 |
Related Pages
JavaScript Tutorial: JavaScript Errors
JavaScript Reference: The message property
❮
Reference
❯