首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

Error.prototype

Error.prototype 属性代表 Error的构造器。

| Error.prototype 属性的属性特性: |

|:----|

| Writable | no |

| Enumerable | no |

| Configurable | no |

描述

所有 Error 与 非标准Error 的实例都继承自 Error.prototype。同所有构造器函数一样,你可以在构造器的 prototype 上添加属性或者方法,使其在所有该构造器的实例上生效。

属性

标准属性

Error.prototype.constructor实例原型的构造函数。

Error.prototype.message错误信息。

Error.prototype.name错误名。

厂商特定扩展属性

非标准

该特性是非标准的,请尽量不要在生产环境中使用它!

Microsoft

Error.prototype.description错误描述,与 message相似。

Error.prototype.number错误码。

Mozilla

Error.prototype.fileName产生该错误的文件名。

Error.prototype.lineNumber产生该错误的行号。

Error.prototype.columnNumber产生该错误的列号。

Error.prototype.stack错误堆栈。

方法

Error.prototype.toSource()返回一个包含特定 Error对象的源代码字符串,你可以用该值新建一个新的对象,重写自 Object.prototype.toSource()方法。

Error.prototype.toString()返回一个表示该对象的字符串,重写自 Object.prototype.toString()方法。

规范

Specification

Status

Comment

ECMAScript 1st Edition (ECMA-262)

Standard

Initial definition. Implemented in JavaScript 1.1.

ECMAScript 5.1 (ECMA-262)The definition of 'Error' in that specification.

Standard

ECMAScript 2015 (6th Edition, ECMA-262)The definition of 'Error' in that specification.

Standard

ECMAScript Latest Draft (ECMA-262)The definition of 'Error' in that specification.

Living Standard

浏览器兼容性

Feature

Chrome

Edge

Firefox

Internet Explorer

Opera

Safari

Basic Support

(Yes)

(Yes)

(Yes)

6

(Yes)

(Yes)

Feature

Android

Chrome for Android

Edge mobile

Firefox for Android

IE mobile

Opera Android

iOS Safari

Basic Support

(Yes)

(Yes)

(Yes)

(Yes)

8.1

(Yes)

(Yes)

扫码关注腾讯云开发者

领取腾讯云代金券