Console log()
Definition and Usage
The log()
method writes (logs) a message to the console.
The log()
method is useful for testing purposes.
Note
When testing console methods, be sure to have the console view visible.
Press F12 to open the console veiw.
Syntax
console.log(message)
Parameters
Parameter | Description |
message | Required. The message to write to the console. |
More Examples
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 »
Browser Support
console.log()
is supported in all browsers:
Chrome | IE | Edge | Firefox | Safari | Opera |
Yes | 8-11 | Yes | Yes | Yes | Yes |