Source Unsplash.

Member-only story

3 little console.log tricks.

Elias Klemm
Jan 4, 2021

I’m quite old-school when it comes to debugging JavaScript applications. I usually prefer to place a simple console.log in my code instead of spinning off the debugger. Here are some tiny console.log tricks that can make your life (at least a little bit) easier:

Wrap your output

Wrapping your output gives you the object name out of the box. This might seem useless, but it makes you a bit faster while debugging:

Format big outputs

It’s sometimes useful to log the whole map without having attributes hidden in the ugly [object, object]:

Console.log in arrow functions

Have you ever been annoyed by adding a console.log in an arrow function without a function body? Did you know that you can do this?

That’s it! :)

Elias

--

--

Elias Klemm
Elias Klemm

Written by Elias Klemm

Software Engineer @ SumUp, Software Architecture Enthusiast, and writing Newby.

No responses yet

Write a response