console.log() is of great help for debugging Javascript code .
But writing them is time consuming. You can save time by following these two tricks:
-
Enclose variables in curly braces :
console.log({input}) instead of console.log(“input”,input)
Create a global variable and assign console.log() function to it . Use that variable instead of console.log
Demo for the above two :
Top comments (9)
nice tips. I find console.table very nice to display for example arrays in a very nice way!
Yeah it's a good way to display
ℹ always 4get about that!
that is nice too!
We can do more with it:
console.log({input})
is not better than console.log(input)console.dir({obj}, {depth: null})
was an eye opening for me.
glad that it helped you :)
Neat tip. Love the first one more especially.
thank you :)