HTML DOM console.error() 方法
- Previous Page count()
- Next Page group()
- Go to the Previous Level Window Console Object
定义和用法
console.error() 方法将错误消息写入控制台。
控制台对于测试非常有用。
提示:在测试此方法时,请确保控制台视图可见(按 F12 查看控制台)。
实例
例子 1
向控制台写入错误:
console.error("You made a mistake");
例子 2
使用对象作为错误消息:
var myObj = { firstname : "Bill", lastname : "Gates" }; console.error(myObj);
例子 3
使用数组作为错误消息:
var myArr = ["Orange", "Banana", "Mango", "Kiwi" ]; console.error(myArr);
语法
console.error(message)
参数值
参数 | 类型 | 描述 |
---|---|---|
message | String or Object | Required. As an error message or object to be written. |
Browser Support
The numbers in the table indicate the first browser version that fully supports this method.
Method | Chrome | IE | Firefox | Safari | Opera |
---|---|---|---|---|---|
console.error() | Support | 8.0 | 4.0 | Support | Support |
- Previous Page count()
- Next Page group()
- Go to the Previous Level Window Console Object