Web/JavaScript/Reference/Global objects/Error/name

From Get docs


The name property represents a name for the type of error. The initial value is "Error".

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

Throwing a custom error

var e = new Error('Malformed input'); // e.name is 'Error'

e.name = 'ParseError';
throw e;
// e.toString() would return 'ParseError: Malformed input'

Specifications

Specification
ECMAScript (ECMA-262)The definition of 'Error.prototype.name' in that specification.

Browser compatibility

Update compatibility data on GitHub

Desktop Mobile Server
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet Node.js
name Chrome

Full support 1

Edge

Full support 12

Firefox

Full support 1

IE

Full support 6

Opera

Full support 4

Safari

Full support 1

WebView Android

Full support 1

Chrome Android

Full support 18

Firefox Android

Full support 4

Opera Android

Full support 10.1

Safari iOS

Full support 1

Samsung Internet Android

Full support 1.0

nodejs

Full support 0.1.100

Legend

Full support  
Full support


See also