English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML DOM console.warn() Method

 JavaScript Console Object

console.warn()Method writes a warning message to the console.

Typically, warnings are in a yellow background in the Web console log and are accompanied by a small exclamation mark icon.

This console can be used for testing or debugging purposes.

Syntax:

console.warn(message)
console.warn("This is a warning message!!!");
Test and see‹/›

Browser Compatibility

All browsers fully support the console.warn() method:

Method
console.warn()YesYesYesYesYes

Parameter Value

ParameterDescription
MessageString or object to be written to the console

More Examples

This example writes an object to the console:

var myObj = { str: "Some text", id: 12 };
console.warn(myObj);
Test and see‹/›

This example writes an array to the console:

var arr = ["Item1", "Item2", "Item3", "Item4"];
console.warn(arr);
Test and see‹/›

 JavaScript Console Object