コンソールテーブル()
例
コンソールにテーブルとして配列を書き込みます。
console.table(["Audi", "Volvo", "Ford"]);
コンソールでオブジェクトをテーブルとして書き込みます。
console.table({firstname:"John", lastname:"Doe"});
以下のその他の例。
定義と使用法
このtable()
メソッドは、テーブルをコンソールに書き込みます。
ノート
列名をクリックすると、テーブルを並べ替えることができます。
構文
console.table(tabledata, tablecolumns)
パラメーター
Parameter | Description |
tabledata | Required. The data to fill the table with. |
tablecolumns | Optional. An array with the names of the table columns. |
その他の例
オブジェクトの配列を使用する:
const car1 = {name:"Audi", model:"A4"}
const car2 = {name:"Volvo", model:"XC90"}
const car3 = {name:"Ford", model:"Fusion"}
console.table([car1, car2, car3]);
表には「モデル」列のみを含めてください。
const car1 = {name:"Audi", model:"A4"}
const car2 = {name:"Volvo", model:"XC90"}
const car3 = {name:"Ford", model:"Fusion"}
console.table([car1, car2, car3], ["model"]);
ブラウザのサポート
console.table()
最新のすべてのブラウザでサポートされています。
Chrome | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes |
console.table()
Internet Explorer 11(またはそれ以前)ではサポートされていません。