The legendary debugging tool. Simple to use, straight to the point and probably one of the first things you learnt when you started with JavaScript. However, relying on console.log to debug your application will soon become a tedious nightmare. Today we will start with the first step to debugging better: the console family.
The Console Family
Please note that ‘console family’ is not a formal term. I just made it up for simplicity
The Console family can actually perform quite a number of things that make debugging a little easier. Lets begin with the classic one

You simply output a variable or string. That’s it. Thank you for coming to my Ted Talk.


If you don’t want to output the entire object that you’re evaluating, you can use console.assert(). How does it work? Well, it receives two arguments, the first one being the variable you want to check if it has data and the second is the error string to be displayed if there is no value in the first argument. So what console.assert checks is if the first value is true or not, if it is true, it does not run. If it is, it prints out the string in the second argument.

The output would be:
What if you want to categorize or group your console messages? This is where comes in. it works in conjunction with console.groupEnd(). It simply appends any console.log messages after it but before console.groupEnd(). See example below

The output would be:



If you have objects in an array or just a large object, console.table is very handy. What it does is put the data into a a table for better visualization

The output would be:



No, this does not stop time. What it does do though is help you measure how long part of your functions runs for. It works with console.timeEnd. see example

and the output would be:

Which indicates the time it took for the code to execute.


There are many other functions within the console family however, I chose to highlight the ones I often use. Which one do you use the most and are there any you would like me to cover that I haven’t? Add your comments below and we will chat