As a web developer, it’s necessary that you be familiar with console.log(). It is the most straightforward approach to troubleshoot anything by logging the value of variables in developer tools. But the console API is much more than that, it provides many other methods that can you help in debugging.

If you have only used console.log() and a couple of other methods for debugging,** I guarantee**that after reading this article you will learn new console methods that will take your JavaScript debugging to the next level.

List of all the console methods that are explained in this article:

  1. console.log
  2. console.clear
  3. console.warn
  4. console.table
  5. console.dir
  6. console.group and console .groupCollapsed
  7. console.count and console.countReset
  8. console.assert
  9. Console.error
  10. console.time and console.timeEnd
  11. console.trace

1. console.log

This is the most common method for general-purpose logging. This function simply outputs any variables/strings to the console. You can list multiple variables/strings by using a comma between them.

I have illustrated a few examples below:

console.log('Simple console message')

/**** Output ****/
// Simple console message 
const str1 = 'Hello'
const str2 = 'World'

console.log(str1, str2)

/****  Output  ****/
// Hello World

#javascript #javascript-tips #debugging #programming #console

JavaScript Console: Take Debugging to Next Level
1.25 GEEK