HTML DOM console.log() Method
THE WORLD'S LARGEST WEB DEVELOPER SITE

HTML DOM console.log() Method

❮ Console Object

Example

Write to the console:

console.log("Hello world!");
Try it Yourself »

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(myObj);
Try it Yourself »

❮ Console Object