5 Methods You should use when Debugging JavaScript and Node

5 Methods You should use when Debugging JavaScript and Node

Moving beyond console.log and learn 5 console methods You should use when Debugging JavaScript and Node

The Console API

Every JavaScript developer has used console.log(‘text’). The console module is one of the most common utilities in JavaScript, and the API implemented in Node:

Provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers.

This is the definition written in the Node.js documentation page for the Console module. However, beginners are prone to consult online tutorials instead of reading the documentation while starting with new technologies, missing the chance to learn how to properly use this new tool to 100% of its potential.

When talking about the Console API, newbies usually use only some functions like console.log(), ⚠️ console.warn(), or console.error() to debug their application, while often there are many other methods which can perfectly implement our requirements and improve debugging efficiency.

This article is made to expose some of the most interesting console methods with related examples that I use while teaching at Codeworks. So let’s see a list of the 8 best functions from the Console module!

All the following methods are available in the global instance console, so it is not necessary to require the console module.

1) console.assert

The console.assert function is used to test if the passed argument is a truthy or falsey value. In the case that the passed value is falsey, the function logs the extra arguments passed after the first one, otherwise, the code execution proceeds without any log.

Both cases of a truthy or falsy assertion.

The assert method is particularly useful whenever you want to check the existence of values while keeping the console clean (avoid logging long list of properties, etc.).

2) console.count and console.countReset

These two methods are used to set and clear a counter of how many times a particular string gets logged in the console:

Count and reset the log occurrences for the “Hello” string.

3) console.group and console.groupEnd

.group and .groupEnd create and end a group of logs in your console. You can pass a label as the first argument of .group() to describe what it is concerned about:

4) console.table

This particular method is incredibly useful to describe an object or array content in a human-friendly table:

Table for a list of user objects.

console.table makes it easier for the inspection and logging of nested and complex arrays/objects.

5) console.time and console.timeEnd

In the case that you want to check the performance of your code in execution time, and to solve it you create a start timestamp with the Date API and use it to compute the difference after your code execution? Something like this:

Well, using the time and timeEnd functions, it is not necessary to do this trick. You can create your timing report simply by doing:

As you can see, console.time also returns a more accurate result.


With only 3 minutes of your time, you now have a larger scope of some of the wonderful tools available in the Console API. Integrate them with your debugging habits and your development speed will increase exponentially!

javascript node-js web-development

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Hire Node.JS Developers | Skenix Infotech

We are providing robust Node.JS Development Services with expert Node.js Developers. Get affordable Node.JS Web Development services from Skenix Infotech.

How to Hire Node.js Developers And How Much Does It Cost?

A Guide to Hire Node.js Developers who can help you create fast and efficient web applications. Also, know how much does it cost to hire Node.js Developers.

Top Node.js Development Companies and Expert NodeJS Developers

A thoroughly researched list of top NodeJS development companies with ratings & reviews to help hire the best Node.JS developers who provide development services and solutions across the world. List of Leading Node.js development Service Providers...

Hire Web Developer

Looking for an attractive & user-friendly web developer? HourlyDeveloper.io, a leading web, and mobile app development company, offers web developers for hire through flexible engagement models. You can **[Hire Web...

Top Vue.js Developers in USA

Vue.js is an extensively popular JavaScript framework with which you can create powerful as well as interactive interfaces. Vue.js is the best framework when it comes to building a single web and mobile apps.