Handy console.log tip: display variables names

We're yet to see a JavaScript developer that doesn't use console.log to perform a "quick debug". And it goes like this:

let theAnswer = 42

And the console will oblidge, showing:


Encapsulate in an object

Here is a handy tip: encapsulate the variable in an object and the variable name will be displayed:

console.log( { theAnswer } );

The output will now be:

{theAnswer: 42}

Happy debugging!