HTML DOM console.table() method
Example
Output a table on the console
console
.
table
(
[
"
"
,
"
Runoob
"
,
"
Taobao
"
]
)
;
Try it »
Definition and Usage
The console.table() method is used to output table information on the console.
The first parameter is required, and its object type must be an object or an array; the corresponding data will be filled into the table.
Tip: During testing of 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
| Parameters | Type | Description |
|---|---|---|
| tabledata | Array or Object | Required. The data to fill into the table. |
| tablecolumns | Array | Optional. An array containing the names of the table header columns. |
More examples
Example
Use an object as the output information:
console
.
table
(
{
name
:
"
Runoob Tutorial
"
,
site
:
"
www.runoob.com
"
}
)
;
Try it »
Example
Use an array of objects:
var
site1
=
{
name
:
"
Runoob
"
,
site
:
"
www.runoob.com
"
}
var
site2
=
{
name
:
"
"
,
site
:
"
www.google.com
"
}
var
site3
=
{
name
:
"
Taobao
"
,
site
:
"
www.taobao.com
"
}
console
.
table
(
[
site1
,
site2
,
site3
]
)
;
Try it »
Example
Specify the table header title names; the parameter can only be the corresponding key names:
var
site1
=
{
name
:
"
Runoob
"
,
site
:
"
www.runoob.com
"
}
var
site2
=
{
name
:
"
"
,
site
:
"
www.google.com
"
}
var
site3
=
{
name
:
"
Taobao
"
,
site
:
"
www.taobao.com
"
}
console
.
table
(
[
site1
,
site2
,
site3
]
,
[
"
site
"
]
)
;
Try it »
Console object