Elizbeth
Elizbeth

Reputation: 59

Why we use console.table method?

I know one of the most basic debugging tools in JavaScript is console.log(). The console comes with several other useful methods that can add to a developer’s debugging toolkit. but I'm pretty confused about console.table() method. Is anyone explain?

Upvotes: 0

Views: 354

Answers (1)

Rizwan
Rizwan

Reputation: 4453

The Console Object: The console object gives you access to the browser’s console. It lets you output strings, arrays, and objects that help debug your code. The console is part of the window object, and is supplied by the Browser Object Model (BOM).

There are four different ways of outputting a message to the console:

  1. log
  2. info
  3. warn
  4. error

while there is another method that is:

console.table()

let me explain The table method displays an array or object as a table.

console.table(['Javascript', 'PHP', 'Perl', 'C++']);

example:

const superhero = { 
    firstname: 'Peter',
    lastname: 'Parker',
}
console.table(superhero);

Upvotes: 1

Related Questions