pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Error/message

ipt>

此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。

View in English Always switch to English

Error: message

基线 广泛可用

自 2015年7月 起,此特性已在主流浏览器中得到支持,可在大多数设备和浏览器版本中正常使用。

Error 实例的 message 数据属性是错误的人类可读描述。

一个字符串,对应于作为第一个参数传递给 Error() 构造函数的值。

Error: message 的属性特性
可写
可枚举
可配置

描述

此属性包含错误的简要描述(如果存在或已被设置)。message 属性与 name 属性一起被 Error.prototype.toString() 方法使用来创建错误的字符串表示形式。

默认情况下,message 属性为空字符串,但可以通过将消息作为第一个参数传递给 Error 构造函数来覆盖实例的此行为。

示例

抛出自定义错误

js
const e = new Error("无法解析输入");
// e.message 是“无法解析输入”
throw e;

规范

规范
ECMAScript® 2027 Language Specification
# sec-error.prototype.message

浏览器兼容性

参见

pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy