Use console.log() like a pro!
The console object provides access to the browser’s debugging console. The specifics of how it works varies from browser to browser, but there is a de facto set of features that are typically provided.
The most common Console methods:
console.log() – For general output of logging information.
console. info() – Informative logging of information.
console.debug() – Outputs a message to the console with the log level debug.
console.warn() – Outputs a warning message.
console.error() – Outputs an error message.
Custom CSS styles for a console.log()
console.log output can be styled in DevTools using the CSS format specifier.
When passing a string to one of the console object’s methods that accept a string (such as log()), you may use these substitution strings:
Log a message and stack trace to console if the first argument is false.
Clear the console.
Log the number of times this line has been called with the given label.
Creates a new inline group, indenting all following output by another level. To move back out a level, call
HTML elements in the console
The memory property can be used to check out the heap size status
Note: memory is a property and not a method.
Displays tabular data as a table.
console.time() – Starts a timer with a name specified as an input parameter. Up to 10,000 simultaneous timers can run on a given page.
console.timeEnd() – Stops the specified timer and logs the elapsed time in seconds since it started.
Outputs a stack trace.
Happy coding! ❤️
If you liked this article, be sure to ❤️ it.
If you like what I write, chances are you'd love what I email. Consider subscribing to my newsletter.
Thanks for this cool tricks! I often just use console.log but ill try to use these options as well. Especially console.table was very useful to me.
Good base article.
Like having the color settings included.
You might also want to mention somewhere in the article that