Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Error.prototype.name

概述

name 属性表示error类型的名称.初始值为"Error".

描述

默认情况下,Error对象的name属性值为"Error".name属性和message属性一起,通过调用Error.prototype.toString()方法,会作为最后异常信息的字符串表示.

示例

例子: 抛出一个自定义错误

var e = new Error("Malformed input"); // e.name默认是"Error"

e.name = "ParseError";                // 修改之后,e.toString()会成为下面这样的字符串
throw e;                              // "ParseError: Malformed input"

规范

Specification Status Comment
ECMAScript 1st Edition. Standard Initial definition.
ECMAScript 5.1 (ECMA-262)
Error.prototype.name
Standard  
ECMAScript 6 (ECMA-262)
Error.prototype.name
Release Candidate  

浏览器兼容性

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support (Yes) (Yes) (Yes) (Yes) (Yes)
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support (Yes) (Yes) (Yes) (Yes) (Yes) (Yes)

相关链接

文档标签和贡献者

 此页面的贡献者: yenshen, teoli, ziyunfei
 最后编辑者: yenshen,