Write a warning to the console:
console.warn("This is a warning!");
Try it Yourself »
More examples below.
The warn()
method writes a warning to the console.
When testing console methods, be sure to have the console view visible.
Press F12 to open the console veiw.
console.warn(
message)
Parameter | Description |
message | Required. The message (warning) to write to the console. |
Use an object as the warning message:
const myObj = {firstname:"John", lastname:"Doe"};
console.warn(myObj);
Try it Yourself »
Use an array as the warning message:
const myArr = ["Orange", "Banana", "Mango", "Kiwi"];
console.warn(myArr);
Try it Yourself »
console.warn()
is supported in all browsers:
Chrome | IE | Edge | Firefox | Safari | Opera |
Yes | 8-11 | Yes | Yes | Yes | Yes |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!