10 Unknown Console Commands in JavaScript: 3 Minute Guide #05
Use 10 Unknown Commands to get the best Console Statements
As a JavaScript developer and I am myself one of them, console.log
is the built-in debugger of JavaScript. I use it pretty often to verify my own code and you should do it, too. There is nothing wrong with doing it this way!
But you can bring your debugging game to the next level and save a lot of time and stress using the provided, mostly unknown, features of console.log
.
1. Inception — Console.log(console)
So you run console.log
to debug something, bring console.log(console)
in your coding game to get more information than you ever will need.
2. Log an Error — console.assert(bool,…)
Whenever you want to simply detect an error, don’t use console.log("ERROR")
. Instead, use console.assert
and it produces an error whenever the first argument has a value of false
.