Download to read offline

![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:](https://image.slidesharecdn.com/5ia1syhsq0wxpn48gtoj-signature-462b907378fa4afebe6f68aea3b83b74f0fbfaa63fdaf3050724e30449d0a66e-poli-200611151348/75/Logging-in-JavaScript-Part-5-2-2048.jpg)
![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.](https://image.slidesharecdn.com/5ia1syhsq0wxpn48gtoj-signature-462b907378fa4afebe6f68aea3b83b74f0fbfaa63fdaf3050724e30449d0a66e-poli-200611151348/75/Logging-in-JavaScript-Part-5-3-2048.jpg)
![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:](https://image.slidesharecdn.com/5ia1syhsq0wxpn48gtoj-signature-462b907378fa4afebe6f68aea3b83b74f0fbfaa63fdaf3050724e30449d0a66e-poli-200611151348/75/Logging-in-JavaScript-Part-5-4-2048.jpg)
![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](https://image.slidesharecdn.com/5ia1syhsq0wxpn48gtoj-signature-462b907378fa4afebe6f68aea3b83b74f0fbfaa63fdaf3050724e30449d0a66e-poli-200611151348/75/Logging-in-JavaScript-Part-5-5-2048.jpg)

The document explains the use of console.table() for displaying JSON data in a tabular format in the console. It demonstrates various examples, including arrays, objects, and how nested objects are displayed. Additionally, it mentions the built-in sorting feature that allows users to sort the table by clicking on column headers.

![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:](https://image.slidesharecdn.com/5ia1syhsq0wxpn48gtoj-signature-462b907378fa4afebe6f68aea3b83b74f0fbfaa63fdaf3050724e30449d0a66e-poli-200611151348/75/Logging-in-JavaScript-Part-5-2-2048.jpg)
![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.](https://image.slidesharecdn.com/5ia1syhsq0wxpn48gtoj-signature-462b907378fa4afebe6f68aea3b83b74f0fbfaa63fdaf3050724e30449d0a66e-poli-200611151348/75/Logging-in-JavaScript-Part-5-3-2048.jpg)
![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:](https://image.slidesharecdn.com/5ia1syhsq0wxpn48gtoj-signature-462b907378fa4afebe6f68aea3b83b74f0fbfaa63fdaf3050724e30449d0a66e-poli-200611151348/75/Logging-in-JavaScript-Part-5-4-2048.jpg)
![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](https://image.slidesharecdn.com/5ia1syhsq0wxpn48gtoj-signature-462b907378fa4afebe6f68aea3b83b74f0fbfaa63fdaf3050724e30449d0a66e-poli-200611151348/75/Logging-in-JavaScript-Part-5-5-2048.jpg)