返回或设置与特定错误相关联的描述性字符串。
object.description
- object
必选。Error 对象的实例。
description 属性是一个字符串,该字符串包含与特定错误相关的错误信息。使用该属性中包含的值向用户发出一个错误警报,指出脚本无法处理。
description 和 message 属性引用相同的消息;description 属性提供向后兼容性,而 message 属性符合 ECMA 标准。
示例下面的示例导致引发了异常,并显示了错误的说明。
function getAge(age) { if(age < 0) throw new Error("An age cannot be negative.") print("Age is "+age+"."); } // Pass the getAge an invalid argument. try { getAge(-5); } catch(e) { print(e.description); }
该代码的输出为:
An age cannot be negative.要求
应用于:
参考
number 属性message 属性 (JScript)
name 属性