console.table()
Displays tabular data as a table in the console.
Syntax
console.table(data, columns)
Returns
undefined — Returns `undefined`.
Examples
console.table([
{ name: "Ada", age: 36 },
{ name: "Lin", age: 28 },
]);
Output
┌─────────┬───────┬─────┐
│ (index) │ name │ age │
├─────────┼───────┼─────┤
│ 0 │ 'Ada' │ 36 │
│ 1 │ 'Lin' │ 28 │
└─────────┴───────┴─────┘
console.table({ a: 1, b: 2 });
Output
┌─────────┬────────┐
│ (index) │ Values │
├─────────┼────────┤
│ a │ 1 │
│ b │ 2 │
└─────────┴────────┘
Notes
- Accepts arrays or objects; nested objects become columns.
- The optional second argument selects which columns to display.
- Exact rendering differs between Node.js and browser devtools.
Browser & runtime support
| Environment | Since version |
|---|---|
| chrome | 27 |
| firefox | 34 |
| safari | 9 |
| edge | 12 |
| node | 10.0 |