Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML DOM console.error() method

HTML DOM console.error() method

Console Object Console object

Example

Output an error message to the console:

console

.

error

(

"

This is an error.

"

)

;

Try it »


Definition and Usage

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

This method is very helpful for testing during development.

Tip: During testing of 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 this method.

Method
console.error() Yes 8.0 4.0 Yes Yes

Parameter Description

Parameters 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

:

"

Runoob Tutorial

"

,

site

:

"

www.runoob.com

"

}

;

console

.

error

(

myObj

)

;

Try it »

Example

Use an array as the error message:

var

myArr

=

[

"

Google

"

,

"

Taobao

"

,

"

Runoob

"

,

"

Facebook

"

]

;

console

.

error

(

myArr

)

;

Try it »

Console Object Console object