HTML DOM console.table() method
- Previous Page log()
- Next Page time()
- Go to the Previous Level Window Console Object
Definition and usage
The console.table() method writes a table in the console view.
The first parameter is required and must be an object or an array containing the data to be filled in the table.
Tip:When testing console methods, make sure the console view is visible (press F12 to view the console).
Instance
Example 1
Write a table in the console:
console.table(["Audi", "Volvo", "Ford"]);
Example 2
Using an object as the first parameter:
console.table({ firstname : "Bill", lastname : "Gates" });
Example 3
Using an object array:
var car1 = { name : "Audi", model : "A4" } var car2 = { name : "Volvo", model : "XC90" } var car3 = { name : "Ford", model : "Fusion" } console.table([car1, car2, car3]);
Example 4
Specify that we only want to include the "model" column in the table:
var car1 = { name : "Audi", model : "A4" } var car2 = { name : "Volvo", model : "XC90" } var car3 = { name : "Ford", model : "Fusion" } console.table([car1, car2, car3], ["model"]);
Syntax
console.table(tabledata, tablecolumns)
Parameter value
Parameter | Type | Description |
---|---|---|
tabledata | Object or array | Mandatory. To fill in the data for the table. |
tablecolumns | Array | Optional. This array contains the column names to be included in the table. |
Browser Support
The numbers in the table indicate the first browser version that fully supports this method.
Method | Chrome | IE | Firefox | Safari | Opera |
---|---|---|---|---|---|
console.table() | Support | 12 | 34 | Support | Support |
- Previous Page log()
- Next Page time()
- Go to the Previous Level Window Console Object