- All modern browsers have a web console for debugging.
- Console is a global object, meaning it is accessible in the browser window's global scope. You can use it as a straight
All current browsers provide a console that may be accessed through a keyboard shortcut key. To access the browser console:
- In Chrome and other chromium-based browsers, press the F12 key.
- For Mozilla Firefox, use the keyboard shortcuts CTRL + SHIFT + K.
- In Safari, use the keyboard shortcut keys Option + ⌘ + C.
It can also be accessed by right-clicking on a web page and choosing "Inspect" from the menu.
To open the console, click the Console option:
1. console.log( )
This method is mainly used to log output to the console. We can use any type within log(), such as a string, array, or object.
console.error can be used to display text on the console:
2. console.clear( )
It's used to clear the console.
3. console.time( ) & console.timeEnd( )
In order to display how many milliseconds a block of code or a function takes to run, use
4. console.table( )
It allows us to generate a table inside a console.
5. console.group( ) & console.groupEnd( )
It is used to move the output to the next level by indenting it:
6. console.count( )
It is used to count the number of times the function is called using this counting method.
7. custom console logs.
Users can add styling to the console logs in order to make logs custom.
If you enjoyed this article, then don't forget to give 💚 and If you have any suggestions or tips, feel free to leave a comment or contact me on Twitter at @ravinwashere. see you later!