Tabular visualization of logs: The console.table() allows to display data in the console in a nice tabular format. const jsonData = [ { color: "red", value: "#f00" }, { color: "green", value: "#0f0" }, { color: "blue", value: "#00f" } ]; console.table(jsonData); Output:
Any type of JSON can be represented in a tabular view. const y = [ ["One", "Two"], ["Three", "Four"] ]; Output: You can display an Array of Arrays in a tabular view const x = { a: 1, b: { a: 1 } }; Output: And, you can also display an object in a tabular view. You may wonder how? Take a look at this example.
console.table() displays any object data in a tabular view. But, if a JSON has multiple nested objects inside, it just prints the root level objects in the tabular view. Let’s see that in this example, const x = [ { p: 123, i: 1 }, { p: 124, i: 2, x: { a: 1, b: { s: 23 } } } ]; Output:
console.table() comes with an inbuilt sorting. You can sort the table by a particular column by clicking on that column's label. const y = [ ["One", "Two"], ["Three", "Four"] ]; console.table(y); Output: Sorting in logs

Logging in JavaScript - Part-5

  • 2.
    Tabular visualization oflogs: The console.table() allows to display data in the console in a nice tabular format. const jsonData = [ { color: "red", value: "#f00" }, { color: "green", value: "#0f0" }, { color: "blue", value: "#00f" } ]; console.table(jsonData); Output:
  • 3.
    Any type ofJSON can be represented in a tabular view. const y = [ ["One", "Two"], ["Three", "Four"] ]; Output: You can display an Array of Arrays in a tabular view const x = { a: 1, b: { a: 1 } }; Output: And, you can also display an object in a tabular view. You may wonder how? Take a look at this example.
  • 4.
    console.table() displays anyobject data in a tabular view. But, if a JSON has multiple nested objects inside, it just prints the root level objects in the tabular view. Let’s see that in this example, const x = [ { p: 123, i: 1 }, { p: 124, i: 2, x: { a: 1, b: { s: 23 } } } ]; Output:
  • 5.
    console.table() comes withan inbuilt sorting. You can sort the table by a particular column by clicking on that column's label. const y = [ ["One", "Two"], ["Three", "Four"] ]; console.table(y); Output: Sorting in logs