HTML DOM console.error()Method

Console 对象Console Object

Example

Output error messages to the console:

console.error("This is an error.");

Try it Yourself »

Definition and Usage

The console.error() method is used to output error messages to the console.

This method is helpful for testing during the development process.

Tip:When testing this method, the console needs to be visible (press F12 in the browser to open the console).


Syntax

console.error(message)

Browser Support

The numbers in the table indicate the first browser version that supports the method.

Method
console.error() Yes 8.0 4.0 Yes Yes

Parameter Details

Parameter Type Description
message String or Object Required. An error message, which can be a string or an object.

More Examples

Example

Use an object as the error message:

var myObj = { name : "Example", site : "www.example.com" }; console.error(myObj);

Try it Yourself »

Example

Use an array as the error message:

var myArr = ["Google", "Taobao", "Example", "Facebook" ]; console.error(myArr);

Try it Yourself »

Console 对象Console Object

Other Extensions