Encodera

Thanks for reading!

Donate to the site — we work hard for you.

JavaScript reference

console.table

Shows an array of objects as a table in the browser console.

Available since: Web API

Syntax

console.table(data, columns)

Parameters

ParameterTypeDescription
dataArray | objectAn array or object to show as a table.
columnsstring[]Optional. Which columns to show.

Return value

undefinedReturns nothing.

Examples

A table of users (output in the browser console):

const users = [
  { name: 'Anna', age: 25 },
  { name: 'Oleg', age: 31 },
];
 
console.table(users);

Output:

┌─────────┬────────┬─────┐
│ (index) │ name   │ age │
├─────────┼────────┼─────┤
│ 0       │ 'Anna' │ 25  │
│ 1       │ 'Oleg' │ 31  │
└─────────┴────────┴─────┘

Notes

Handy for inspecting server data. The example above does not run on this site: the table appears only in a real browser console (F12) or in a Node.js terminal.

See also

Related recipes

In the tutorial

  • Debugging — How to find bugs in JavaScript: reading the error message, console.log and its variants, checking types, developer tools and debugger.

Thanks for reading!

Donate to the site — we work hard for you.