HTML DOM console.log() method
- Previous Page info()
- Next Page table()
- Go to the Previous Level Window Console Object
Definition and usage
The console.log() method writes messages to the console.
The console can be used for testing purposes.
Tip:When testing this method, make sure the console view is visible (press F12 to view the console).
Instance
Example 1
Write to the console:
console.log("Hello world!");
Example 2
Write an object to the console:
var myObj = { firstname : "Bill", lastname : "Gates" }; console.log(myObj);
Example 3
Write an array to the console:
var myArr = ["Orange", "Banana", "Mango", "Kiwi" ]; console.log(myArr);
Syntax
console.log(message)
Parameter value
Parameter | Type | Description |
---|---|---|
message | String or Object | Required. Write messages or objects to the console. |
Browser Support
The numbers in the table indicate the first browser version that fully supports this method.
Method | Chrome | IE | Firefox | Safari | Opera |
---|---|---|---|---|---|
console.log() | Support | 8.0 | 4.0 | Support | Support |
- Previous Page info()
- Next Page table()
- Go to the Previous Level Window Console Object