Learn how to use console.table to render arrays and objects in a tabular format for easy scanning over the values. We'll create some mock data and then render it to the log in various ways to explore console.table's API.

 

function Character(name, power){
    this.name = name;
    this.power = power;
}

var buffy = new Character("buffy", "1");
var joe = new Character("joe", "2");
var john = new Character("john", "3");

var chars = [buffy, joe, john];
console.table(chars);

var chars= {
    buffy,
    joe,
    john
}
console.table(chars);

console.table(chars, ["power"])

console.table(chars, []);

 

[Javascript] Logging Pretty-Printing Tabular Data to the Console_JavaScript

 

[Javascript] Logging Pretty-Printing Tabular Data to the Console_JavaScript_02

 

[Javascript] Logging Pretty-Printing Tabular Data to the Console_JavaScript_03

 

[Javascript] Logging Pretty-Printing Tabular Data to the Console_JavaScript_04