name

Summary

A name for the type of error.

Property of Error
Implemented in JavaScript 1.?
ECMAScript Edition ECMAScript 1st Edition

Description

By default, Error instances are given the name "Error". The name property, in addition to the message property, is used by the Error.prototype.toString method to create a string representation of the error.

Examples

Example: Throwing a custom error

var e = new Error("Malformed input"); // e.name is "Error"
e.name = "ParseError";                // e.toString() would return
throw e;                              // "ParseError: Malformed input"

See also

Tags (0)

Edit tags
  • No tags

Attachments (0)

 

Attach file