错误:message
Error
实例的 message
数据属性是人类可读的错误描述。
¥The message
data property of an Error
instance is a human-readable description of the error.
值
描述
¥Description
此属性包含错误的简要描述(如果可用或已设置)。Error.prototype.toString()
方法使用 message
属性与 name
属性组合来创建错误的字符串表示形式。
¥This property contains a brief description of the error if one is available or has been set. The message
property combined with the name
property is used by the Error.prototype.toString()
method to create a string representation of the Error.
默认情况下,message
属性是空字符串,但可以通过将消息指定为 Error
构造函数的第一个参数来覆盖实例的此行为。
¥By default, the message
property is an empty string, but this behavior can be overridden for an instance by specifying a message as the first argument to the Error
constructor.
示例
抛出自定义错误
规范
Specification |
---|
ECMAScript Language Specification # sec-error.prototype.message |
浏览器兼容性
BCD tables only load in the browser