Table of contents
- 1. Summary
- 2. Description
- 3. Examples
- 4. See also
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"