JavaScript console.table() Method

Write an array as a table in the console

Definition and Usage

The table() method writes a table to the console.

Note

You can sort the table by clicking the column names.

Syntax

console.table(tabledata, tablecolumns)

Parameters

Parameter Description
tabledata Required.
The data to fill the table with.
tablecolumns Optional.
An array with the names of the table columns.

More Examples

Using an array of objects:

const car1 = {name:"Audi", model:"A4"}
const car2 = {name:"Volvo", model:"XC90"}
const car3 = {name:"Ford", model:"Fusion"}

console.table([car1, car2, car3]);

Only include the "model" column in the table:

const car1 = {name:"Audi", model:"A4"}
const car2 = {name:"Volvo", model:"XC90"}
const car3 = {name:"Ford", model:"Fusion"}

console.table([car1, car2, car3], ["model"]);

Browser Support

console.table() is supported in all modern browsers:
Chrome Edge Firefox Safari Opera
Yes Yes Yes Yes Yes
console.table() is not supported in Internet Explorer 11 (or earlier).