DEV Community 👩‍💻👨‍💻

Dhanush N
Dhanush N

Posted on • Originally published at

Javascript Console Methods

There are various console methods in javascript which can be used based on how you want the display to be shown.

  • console.dir()

This method displays an interactive list of all the properties of a specified object.
If you want to log all the properties of a HTML element you can use console.dir instead of console.log

  • console.table()

This method displays tabular data as a table.
The method takes 1 mandatory argument data, which must be an array or an object.
Each element in the array becomes a row in the table.


If you have a lot of logs it can be difficult to keep track of all these logs.
The creates a new inline group in the Web console log causing any subsequent console messages to be indented by an additional level untill console.groupEnd() is called

  • console.time()

This method starts a timer you can use to track how long an operation takes.
You can give each timer a unique name and you can have upto 10000 timers running on a given page.
When you call console.timeEnd() with the same name the browser will output the time in millisecons, that elapsed since the timer was started

  • console.count()

This logs the number of times the particular call to count() has been called.
A string if supplied, count("") outputs the number of times it has been called with that label.
If it is omitted count() behaves as thought it was called with the "default" label.

  • console.assert()

This method writes and error message to the console if the assertion is false.
If assertion is true nothing happens
Eg) console.assert(assertion, message, obj1, obj2, ...)

  • console.log()

This is used to output a message in console

  • console.clear()

This is used to clear the console if it is allowed by the environment

  • console.error()

Outputs an error message to the console.

Thanks for reading ❤️

Connect with me via Twitter, Instagram, Github

Top comments (0)

Take a look at this:


Go to your customization settings to nudge your home feed to show content more relevant to your developer experience level. 🛠