Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / JavaScript

console.table — tabular console output

console.table displays data as a console table. The optional properties argument selects columns; presentation depends on the implementation.

Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support

Syntax

console.table(tabularData, properties);

console.table attempts to display tabularData as a table. If the data cannot be parsed as tabular, it outputs the argument itself instead. In both cases, it passes table as the level to Printer.

Both arguments are optional. properties is a sequence of property names, supplied for example as an array of strings. The example selects name and score, omitting active. The method returns undefined, not a table.

This is a Console Standard API, not a feature of a particular ECMAScript edition. The exact table algorithm remains underspecified. Check availability and presentation in the target browser; Node 24 does not establish browser support.

Examples

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>console.table example</title>
</head>
<body>
  <main><pre id="result"></pre></main>
  <script>
    const result = document.getElementById('result');
    if (typeof console.table !== 'function') {
      result.textContent = 'console.table is unavailable.';
    } else {
      const players = [
        { name: 'Ada', score: 12, active: true },
        { name: 'Lin', score: 9, active: false }
      ];
      const columns = ['name', 'score'];
      console.table(players, columns);

      const header = ['(index)', ...columns].join(' | ');
      const rows = players.map((player, index) =>
        [index, ...columns.map(column => player[column])].join(' | ')
      );
      result.textContent = ['Console table preview:', header, ...rows].join('\n');
    }
  </script>
</body>
</html>

Result

Console table preview:
(index) | name | score
0 | Ada | 12
1 | Lin | 9

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources