Ah, debugging... Something we all have to do! You're undoubtedly familiar with the console.log() method. But did you know you can get much prettier output using the console.table() method?

Object literals

Given the following object literal:

var person = {
name: "Kieran",
nationality: "British",
occupation: "Web Developer"
};

I can call console.table(person) to get the following output:

(index)Values
nameKieran
nationalityBritish
occupationWeb Developer

Array literals

It also works with array literals:

var fruits = [
"Apples",
"Bananas",
"Clementines"
];

Calling console.table(fruits) gives me the following output:

(index)Values
0Apples
1Bananas
2Clementines

Summary

The console.table() method prints things to the console in a pretty, readable format. It's a nice alternative to the console.log() method.

For more information, check out console.table() in the MDN Web Docs.