HTML DOM console.warn() method
- Previous Page trace()
- Next Page assert()
- Go to Parent Level Window Console Object
Definition and usage
console.warn()
The method writes a warning to the console.
Tip:When testing this method, make sure the console view is visible (press F12 to view the console).
instance
Example 1
Write a warning to the console:
console.warn("This is a warning!");
Example 2
Use an object as a warning message:
var myObj = { firstname : "Bill", lastname : "Gates" }; console.warn(myObj);
Example 3
Use an array as a warning message:
var myArr = ["Orange", "Banana", "Mango", "Kiwi" ]; console.warn(myObj);
syntax
console.warn(message)
parameter value
parameter | type | description |
---|---|---|
message | String or Object | Required. The message or object written as a warning. |
Browser Support
The numbers in the table indicate the first browser version that fully supports this method.
Method | Chrome | IE | Firefox | Safari | Opera |
---|---|---|---|---|---|
console.warn() | Support | 8.0 | 4.0 | Support | Support |
- Previous Page trace()
- Next Page assert()
- Go to Parent Level Window Console Object