7 Console Methods Used by Pros

Often while debugging, beginners use the console.log() method to print out values. But there are a few other console methods that make your life much easier. Want to know what these methods are? Let's dive in!

1. console.table()

Logging matrixes or even long arrays or objects is a headache using the console.log() method. console.table() is a much more elegant way to do it.

// Matrix
["apple", "banana", "cherry"],
["Rs 80/kg", "Rs 100/kg", "Rs 120/kg"],
["5 ⭐", "4 ⭐", "4.5 ⭐"],
// Maps
class Person {
constructor(firstName, lastName) {
this.firstName = firstName;
this.lastName = lastName;
const family = {};
family.mother = new Person("Jane", "Smith");
family.father = new Person("John", "Smith");
family.daughter = new Person("Emily", "Smith");

2. console.trace()

Are you having issues debugging a function? Left wondering how the execution flows? console.trace() is your friend!

function outerFunction() {
function innerFunction() {

3. console.error() and console.warn()

Tired of boring logs? Spice things up with console.error() and console.warn().

console.error("This is an error message");
console.warn("This is a warning message");
console.log("This is a log message");

4. console.assert()

This is another brilliant tool for debugging! If the assertion fails, the console will print out the trace.

function func() {
const a = -1;
console.assert(a === -1, "a is not equal to -1");
console.assert(a >= 0, "a is negative");

5. console.count() and console.countReset()

Yet another incredible debugging tool! console.count() will print out the number of times it is executed.

function fibonacci(num) {
if (num < 2) {
return num;
return fibonacci(num - 1) + fibonacci(num - 2);
console.log("COUNTER RESET");

6. console.time(), console.timeEnd(), and console.timeLog()

Need to check how long something takes? The timer methods are there to rescue you!

console.time("timeout-timer");setTimeout(() => {
}, 1000);
setTimeout(() => {
}, 500);

NOTE: The setTimeouts are not executed immediately, resulting in a small deviation from the expected time.

7. console.clear()

After logging so much to the console, of course, you would need to clear it up for further use. The console.clear() method is the way to go!

console.log("Some random text");

That’s all folks! Hope this helps you become a better, well-rounded developer!

Research says, writing down your goals on pen & paper makes you 21% to 39% more likely to achieve them. Check out these notebooks and journals to make the journey of achieving your dreams easier: https://www.amazon.com/Tapajyoti-Bose/e/B09VGDDHRR

Follow me for weekly new tidbits on the domain of tech!

Need a Top Rated Front-End Development Freelancer to chop away your development woes? Contact me on Upwork

Want to see what I am working on? Check out my Personal Website and GitHub

Want to connect? Reach out to me on LinkedIn

Follow me on Instagram to check out what I am up to recently.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Tapajyoti Bose

Tapajyoti Bose

Top Rated Freelancer || Blogger || Cross-Platform App Developer || Web Developer || Open Source Contributor || FIRE Enthusiast