HTML DOM console.log() Method
More "Try it Yourself" examples below.
Definition and Usage
The console.log() method writes a message to the console.
The console is useful for testing purposes.
Tip: When testing this method, be sure to have the console view visible (press F12 to view the console).
Browser Support
The numbers in the table specify the first browser version that fully supports the method.
Method | |||||
---|---|---|---|---|---|
console.log() | Yes | 8.0 | 4.0 | Yes | Yes |
Syntax
console.log(message)
Parameter Values
Parameter | Type | Description |
---|---|---|
message | String or Object | Required. The message or object to write in the console |
More Examples
Example
Write an object to the console:
var myObj = { firstname : "John", lastname : "Doe" };
console.log(myObj);
Try it Yourself »
Example
Write an Array to the console:
var myArr = ["Orange", "Banana", "Mango", "Kiwi" ];
console.log(myArr);
Try it Yourself »