JavaScript Console table() Tutorial

In this section, we will learn what the window table() method is and how to use it in JavaScript.

JavaScript Console table() Method

The `table()` method is used to send data to a browser console in a tabular format.

Console table() Method Syntax:

console.table(tabledata, tablecolumns)

Console table() Method Parameter:

The method takes two arguments:

  • The first argument is the data that we want to send to the table. This argument must be an object or an array.
  • The second argument is an array of the names for the columns to be included in the table.

Note: the second argument is optional.

Console table() Method Return Value:

The return value of this method is undefined.

Example: using Console table() method in JavaScript

const brands = [

["Apple","Amazon","Microsoft","Nokia"],

["Tesla","BMW","Honda","Toyota"]

]

console.table(brands);

const obj = {

    firstName: "John",

    lastName: "Doe"

}

console.table(obj);

Output:

Open the browser console to see the output.

Facebook
Twitter
Pinterest
LinkedIn

Top Technologies