Console error()
Example
Write an error to the console:
console.error("You made a mistake");
Try it Yourself »
More examples below.
Description
The error()
method writes an error message to the console.
The console is useful for testing purposes.
Syntax
console.error(message)
Parameters
Parameter
Description
message
Required.
The error message to write to the console.
The error message to write to the console.
More Examples
Use an object as the error message:
const myObj = {firstname:"John", lastname:"Doe"};
console.error(myObj);
Try it Yourself »
console.error(myObj);
Use an array as the error message:
const myArr = ["Orange", "Banana", "Mango", "Kiwi"];
console.error(myArr);
Try it Yourself »
console.error(myArr);
Browser Support
console.error()
is supported in all browsers:
Chrome | IE | Edge | Firefox | Safari | Opera |
Yes | 8-11 | Yes | Yes | Yes | Yes |