THE WORLD'S LARGEST WEB DEVELOPER SITE

HTML DOM console.error() Method

❮ Console Object

Example

Write an error to the console:

console.error("You made a mistake");
Try it Yourself »

Definition and Usage

The console.error() method writes an error message to the console.

The console is useful for testing purposes.

Tip: When testing this method, be sure to have the console view visible (press F12 to view the console).


Browser Support

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

Method
console.error() Yes 8.0 4.0 Yes Yes

Syntax

console.error(message)

Parameter Values

Parameter Type Description
message String or Object Required. The message or object to write as an error

More Examples

Example

Use an object as the error message:

var myObj = { firstname : "John", lastname : "Doe" };
console.error(myObj);
Try it Yourself »

Example

Use an Array as the error message:

var myArr = ["Orange", "Banana", "Mango", "Kiwi" ];
console.error(myArr);
Try it Yourself »

❮ Console Object