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

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, []);

 

 

 

 

posted @ 2016-05-17 21:21  Zhentiw  阅读(186)  评论(0)    收藏  举报