Skip to content

Group console.logs in JavaScript

group console logs in JavaScript

If you find yourself trying to group multiple console.log() like this:

Then allow me to show you a better alternative.

You can use console.group() to mark the start of the group and console.groupEnd() to mark the end of the group.

 

Both groups can be collapsed or displayed by clicking the arrow.

🎥 Check out this video for a showcase of this functionality:

 

Additionally, you can collapse a group by default by using the console.groupCollapsed() function.


I hope now it will be much easier for you to handle the logs.

Happy coding 😊


Let me know what you think about this article in the comments section below.

If you find this article helpful, please share it with others and subscribe to the blog to support me, and receive a bi-monthly-ish e-mail notification on my latest articles.   
  

Comments