Kaustubh Pardhi

Kaustubh Pardhi

Magic of Console 🧙🏻‍♀️

Magic of Console 🧙🏻‍♀️

Console

What mdn(Mozilla Developers Network) says 🧐

: Logs information associated with a web page: network requests, JavaScript, CSS, security errors and warnings as well as error, warning and informational messages explicitly logged by JavaScript code running in the page context

What I say 🙃

: console(object) is a bro/buddy of every js developer xd(life saver).

Let's dive into it ğŸ˜Ž

You can open the console by (rightClick => inspect) on any of your web page. console 1.png

<html>
<h1>Hello ,Console !</h1>
</html>

console 3.png

Magic begins from here ğŸŽ©

I hope you know the most basic method of console object that is .log(console.log)

Let's jump into under-rated methods of console

  • console.warn

    The console.warn() method outputs a warning message to the Web console.
console.warn('OH NOOO');
  • console.error

    The console.error() method writes an error message to the console.
 console.error('Shit!');
  • console. info

    The console.info() method outputs an informational message to the Web console. In Firefox, a small "i" icon is displayed next to these items in the Web console's log.
 console.info('Crocodiles eat 3-4 people per year');
  • console.assert

    The console.assert(expression,message) method writes a message to the console, but only if an expression evaluates to false, message can be astring or object.
console.assert(document.getElementById("demo"), "You have no element with ID 'demo'");
  • console.group

    The console.group() method indicates the start of a message group. All messages will from now on be written inside this group. Tip: Use the console.groupEnd() method to end the group. Tip: Use the console.groupCollapsed() method to hide the message group (collapsed by default).

console-group.png

  • console.count

    Writes to the console the number of times that particular console.count() is called. You can add a label that will be included in the console view. By default the label "default" will be added.

console-count.jpg

That's it folks ,Shoot the like button if you found the blog useful 🙌 .

 
Share this