Javascript console.table() Method choose object field

Introduction

Specifying that we only want to include the "model" column in the table:

Press F12 on your keyboard to view the table in the console view.

View in separate window

<!DOCTYPE html>
<html>
<body>
<script>

var car1 = { name : "HTML", model : "mark" }
var car2 = { name : "Javascript", model : "logic" }
var car3 = { name : "CSS", model : "Fusion" }

console.table([car1, car2, car3], ["model"]);

</script>//from  w ww .jav a2  s.com

</body>
</html>

This example demonstrates how to use the second parameter to name the columns you want to include in the table.




PreviousNext

Related