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 NameDescriptionTry it
EvalErrorDeprecated - 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 »

See Also:

The message property of the Error object.



Syntax

errorObj.name

Return Value

Type Description
A stringThe name of the error.

Browser Support

error.name is an ECMAScript1 (ES1) feature.

ES1 (JavaScript 1997) is fully 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


Copyright 1999-2023 by Refsnes Data. All Rights Reserved.