HTML DOM console.table()Method

Console 对象Console Object

Example

Output a table in the console

console.table(["Google", "Example", "Taobao"]);

Try it Yourself »

Definition and Usage

The console.table() method is used to output table information in the console.

The first parameter is required, and the object type needs to be an object or an array; the corresponding data will be filled into the table.

Tip:When testing this method, the console needs to be visible (press F12 in the browser to open the console).


Syntax

console.table(tabledata, tablecolumns)

Browser Support

The numbers in the table indicate the first browser version that supports this method.

Method
console.table() Yes 12 34 Yes Yes

Parameter Description

Parameter Type Description
tabledata Array or Object Required. The data to be filled into the table.
tablecolumns Array Optional. An array containing the names of the table column headers.

More Examples

Example

Use an object as the output information:

console.table({ name : "Example", site : "www.example.com" });

Try it Yourself »

Example

Use an array of objects:

var site1 = { name : "Example", site : "www.example.com" } var site2 = { name : "Google", site : "www.google.com" } var site3 = { name : "Taobao", site : "www.taobao.com" } console.table([site1, site2, site3]);

Try it Yourself »

Example

Specify the names of the table column headers. The parameter can only be the corresponding key names:

var site1 = { name : "Example", site : "www.example.com" } var site2 = { name : "Google", site : "www.google.com" } var site3 = { name : "Taobao", site : "www.taobao.com" } console.table([site1, site2, site3], ["site"]);

Try it Yourself »

Console 对象Console Object

Other Extensions