Write an error to the console:
console.error("You made a mistake");
Try it Yourself »
More examples below.
The error()
method writes an error message to the console.
The console is useful for testing purposes.
console.error(
message)
Parameter | Description |
message | Required. The error message to write to the console. |
Use an object as the error message:
const myObj = {firstname:"John", lastname:"Doe"};
console.error(myObj);
Try it Yourself »
Use an array as the error message:
const myArr = ["Orange", "Banana", "Mango", "Kiwi"];
console.error(myArr);
Try it Yourself »
console.error()
is supported in all browsers:
Chrome | IE | Edge | Firefox | Safari | Opera |
Yes | 8-11 | Yes | Yes | Yes | Yes |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!