Meja konsol()
Contoh
Tulis array sebagai tabel di konsol:
console.table(["Audi", "Volvo", "Ford"]);
Tulis objek sebagai tabel di konsol:
console.table({firstname:"John", lastname:"Doe"});
Lebih banyak contoh di bawah ini.
Definisi dan Penggunaan
Metode table()
ini menulis tabel ke konsol.
Catatan
Anda dapat mengurutkan tabel dengan mengklik nama kolom.
Sintaksis
console.table(tabledata, tablecolumns)
Parameter
Parameter | Description |
tabledata | Required. The data to fill the table with. |
tablecolumns | Optional. An array with the names of the table columns. |
Lebih Banyak Contoh
Menggunakan array objek:
const car1 = {name:"Audi", model:"A4"}
const car2 = {name:"Volvo", model:"XC90"}
const car3 = {name:"Ford", model:"Fusion"}
console.table([car1, car2, car3]);
Hanya sertakan kolom "model" di tabel:
const car1 = {name:"Audi", model:"A4"}
const car2 = {name:"Volvo", model:"XC90"}
const car3 = {name:"Ford", model:"Fusion"}
console.table([car1, car2, car3], ["model"]);
Dukungan Peramban
console.table()
didukung di semua browser modern:
Chrome | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes |
console.table()
tidak didukung di Internet Explorer 11 (atau lebih lama).