Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. JavaScript
  3. Reference
  4. Standard built-in objects
  5. Error
  6. name

Error.prototype.name

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨July 2015⁩.

Thename data property ofError.prototype is shared by allError instances. It represents the name for the type of error. ForError.prototype.name, the initial value is"Error". Subclasses likeTypeError andSyntaxError provide their ownname properties.

Value

A string. ForError.prototype.name, the initial value is"Error".

Property attributes ofError.prototype.name
Writableyes
Enumerableno
Configurableyes

Description

By default,Error instances are given the name "Error". Thename property, in addition to themessage property, is used by theError.prototype.toString() method to create a string representation of the error.

Examples

Throwing a custom error

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

Specifications

Specification
ECMAScript® 2026 Language Specification
# sec-error.prototype.name

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp