Use console.log() like a pro (2020)


Post Author - Marko by Marko | November 23, 2020

The utilization of console.log() for JavaScript debugging is per chance the most current prepare among builders. But, there is more…

The console object affords glean admission to to the browser’s debugging console. The specifics of the intention in which it in actuality works fluctuate from browser to browser, but there is a de facto glean of aspects that are on the entire supplied.

The commonest Console ideas:

  • console.log() – For total output of logging facts.
  • console.facts() – Informative logging of knowledge.
  • console.debug() – Outputs a message to the console with the log stage debug.
  • console.warn() – Outputs a warning message.
  • console.error() – Outputs an error message.

Common Console methods

Custom-made CSS styles for a console.log()

The console.log output can even be styled in DevTools the reveal of the CSS format specifier.

console.log() CSS

String substitutions

When passing a string to indisputably one of many console object’s ideas that accept a string (comparable to log()), you would reveal these substitution strings:

  • %s string
  • %i or %d integer
  • %o or %O object
  • %f stir with the jog

string substitutions


Log a message and stack trace to console if the first argument is fake.



Particular the console.



Log the desire of times this line has been known as with the given ticket.



Displays an interactive list of the properties of the specified JavaScript object.

console.dir() and console.groupEnd()

Creates a brand fresh inline community, indenting all following output by one more stage. To switch abet out a stage, call groupEnd(). and console.groupEnd()

HTML parts in the console

HTML elements in the console


The memory property can even be broken-down to strive the heap size space

Uncover: memory is a property and not a methodology.



Displays tabular facts as a table.


console.time() and console.timeEnd()

  • console.time() – Starts a timer with a name specified as an enter parameter. Up to 10,000 simultaneous timers can journey on a given net page.
  • console.timeEnd() – Stops the specified timer and logs the elapsed time in seconds since it started.

console.timer() and console.timeEnd()


Outputs a stack trace.


Did you really liked this text? Half it along with your of us:


April 11, 2021

Read More

Recent Content