HTML DOM console.warn()Method

Console 对象Console Object

Example

Output a warning message to the console:

console.warn("Example! This is a warning message");

Try it Yourself »

Definition and Usage

The console.warn() method is used to output warning 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.warn(message)

Browser Support

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

Method
console.warn() Yes 8.0 4.0 Yes Yes

Parameter Description

Parameter Type Description
message String or Object Required. The message to display on the console.

More Examples

Example

Use an object as the warning message output:

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

Try it Yourself »

Example

Use an array as the warning message output:

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

Try it Yourself »

Console 对象Console Object

Other Extensions