DEV Community

Cover image for Console Wrangling
Raz Chiriac
Raz Chiriac

Posted on

Console Wrangling

Have you ever console logged the console?

Thanos console

So you know the good ol’ console.log() ?

Well, that’s not the only thing the console can do, it’s only the most basic.

Have you ever used the console to log the console? No? You should try it.

The console will show you what the console can do.

console console

Today we’ll talk about two of the functions available on the console object:

console.table() and console.trace()

Lets say we have two objects:

const carA = {make: 'Ford', model: 'F150', year: '2018', color: 'white'}
const carB = {make: 'Ford', model: 'F250', year: '2016', color: 'blue'}
Enter fullscreen mode Exit fullscreen mode

If we wanted to do some debugging and had to print these objects out to the console we could use console.log() but it wont look too nice.

Look how neat console.table() can display the two objects:

console table

You can even sort the two rows by column just by clicking on the headers!

One other console function we’ll talk about today is console.trace(). This will output a stack trace to the console.

console trace

And that’s all for today.

I hope I’ve helped make your debugging a little less boring. Now go show off your new console skills in your next stand-up.

Cheers!

Top comments (0)