Help us understand the problem. What is going on with this article?

Chromeのコンソールにテーブルを表示する

More than 5 years have passed since last update.

サンプル1

var data = [[1,2], [3,4]];
console.table(data);

sample1.png

サンプル2

var data = {data1:[1,2], data2:[3,4]};
console.table(data);

sample2.png

サンプル3

function Add(name, price){
    this.name = name;
    this.price = price;
}

var data = {};
data[0] = new Add("すごいテレビ", 100);
data[1] = new Add("伝説の雑誌", 200);
data.test = new Add("テスト", 9999);    

console.table(data);

image1.jpeg

console.table未対応ブラウザを考慮する場合

if (void 0 !== window.console && void 0 !== console.table) {
    // 対応していた場合のコードをここ書く
} else {
    alert("このブラウザはconsole.tableに未対応です");
}
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away