JavaScript Error name Attribute

Definition and Usage

The name property sets or returns the error name.

The error name property can return six different values:

Error Name Description Try It
EvalError

Error occurs in the eval() function.

Note:Newer versions of JavaScript will not cause any EvalError. Please use SyntaxError instead.

RangeError Number "out of range" occurs. Try It
ReferenceError Illegal reference occurs. Try It
SyntaxError Syntax error occurs. Try It
TypeError Type error occurs. Try It
URIError Error occurs in encodeURI(). Try It

Hint:See also the error object's message Properties.

Example

Return the error name (we have written "alert" as "adddlert" to intentionally cause an error):

try {
  adddlert("Welcome guest!");
}
catch(err) {
  document.getElementById("demo").innerHTML = err.name;
}

Try It Yourself

Syntax

errorObj.name

Technical Details

Return Value: A string representing the error name.
JavaScript Version: 1.0

Browser Support

Properties Chrome IE Firefox Safari Opera
name Support Support Support Support Support

Related Pages

JavaScript Tutorial:JavaScript Error

JavaScript Reference Manual:message Attribute