THE WORLD'S LARGEST WEB DEVELOPER SITE

JavaScript Error name Property

❮ JavaScript Error 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 NameDescriptionTry it
EvalErrorAn error has occurred in the eval() function. Note: Newer versions of JavaScript does not throw any EvalError. Use SyntaxError instead. 
RangeErrorA number "out of range" has occurredTry it »
ReferenceErrorAn illegal reference has occurredTry it »
SyntaxErrorA syntax error has occurredTry it »
TypeErrorA type error has occurredTry it »
URIErrorAn error in encodeURI() has occurredTry 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

❮ JavaScript Error Reference