Printing in the console is pretty easy all we have to know is how to activate the console on the chrome for viewing. The Console is always active all we are doing is making it visible to the front-end. A console is an object which provides access to the browser’s debugging console. Console object has many methods which help us to print customized debugging.
Here, are the following methods:
- assert(): Acts like ‘if’, prints to console if false.
- clear(): Clears the console.
- count(): counts whenever it gets called.
- error(): prints error if any.
- group(): Creates a new inline group in the console.
- groupCollapsed(): Creates a new inline collapsed group in the console.
- groupEnd(): Exits the inline group in the console.
- info(): acts just as log, for priority info.
- log(): Outputs a message to the console.
- table(): Displays tabular data as a table.
- time(): tracks how long the specific task taking place.
- timeEnd(): ends the tracker.
- trace(): Outputs a stack trace.
- warn(): Outputs a warning message.
Click on F12 after running the script and it opens the Developer Tools, navigate to the Console tab, which will be on the top menu.
After clicking the button:
Example 2: Check out the console.table() for better understanding of methods.
After Clicking the button:
- Text to Voice conversion using Web Speech API of Google Chrome
- Opening google search results simultaneously in new tabs in Chrome
- How to debug PHP scripts ?
- Difference between console.dir and console.log
- What are chrome extensions?
- Chrome Inspect Element Tool & Shortcut
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.