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