HTML DOM console.warn() method
Example
Output a warning message on the console:
console
.
warn
(
"
Runoob! This is a warning message
"
)
;
Try it »
Definition and Usage
The console.warn() method is used to output warning messages on 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.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
| Parameters | Type | Description |
|---|---|---|
| message | String or Object | Required. The information to display on the console. |
More examples
Example
Use an object as the output warning message:
var
myObj
=
{
name
:
"
Runoob Tutorial
"
,
site
:
"
www.runoob.com
"
}
;
console
.
warn
(
myObj
)
;
Try it »
Example
Use an array as the output warning message:
var
myArr
=
[
"
"
,
"
Taobao
"
,
"
Runoob
"
,
"
"
]
;
console
.
warn
(
myArr
)
;
Try it »
Console object