Knowing your tools can make all the difference when it comes to getting things done. Despite JavaScript's reputation for being difficult to debug, if you have a few tricks up your sleeve, errors and problems will take less time to fix.
1.Console.time() and timeEnd(): The console object has time() and timeEnd() methods that help with analysing performance of pieces of your code.
2.Console.trace(): console.trace() to get a quick and easy stack trace to better understand code execution flow.
3.Console.table(): Use console.table instead of console.log to get a nicer formatted output ๐
4.Console.assert(): Conditional logging ( without wrapping your logs with if-else) ๐ You can use console.assert(condition, msg) to log something when the condition is falsy.
4.Bonus Tip: Tired of having to write clear() or console.clear() when debugging in the browser console?
Just define a getter for clear
on the global object that does it for you. Then you can type clear
just like you would in the terminal!!!