您的位置:首页 > Web前端 > JavaScript

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

2016-05-17 21:21 495 查看
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, []);








内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: