In your development career, you mostly know about the console.log() but the console API can do many things that you may not know about. Here, in this article, we are going to learn all about console API with Good VS Bad practices.
Let’s start with consoling the console object.
Write console.log(console) in your browser’s console editor and find the list of APIs provided by the console object. Each API purpose is unique and useful in certain cases.

Below are my explanations of the most useful APIs in console object.
Assume you have an Object on the list and you show that on the JavaScript console.
The Bad Practice

Assertion – Sometimes we want to log only when the condition is false.
console.assert() – If condition is false then only give an error. It eliminates the need for if condition and keeps your code clean.
The Bad Practice

The Good Practice

{ } – Always use Braces to log the object with the name.
The Bad Practice

The Good Practice

Group: If you have multiple logs, then try log group for collapsible sections.
The Bad Practice












Join the conversation! Your thoughts help the community grow.