JavaScript Console Object and Methods
A Javascript console object is a global object that provides access to the browser's debugging console.
Most of us have used console.log() to print messages to the console. but there are many other methods that we can use to debug code easily.
List of JavaScript Console Methods
- console.log();
- Logs a message to the console.
- This method can print strings, numbers, arrays, and objects.
- console.info();
- It is used to display a message to the browser console.
- This is very similar to console.log(); but it is used by developers for permanent messages to output to the console in their code.
- console.warn();
- console.error();
- console.count();
- console.assert();
- Time, Timelog and TimeEnd
- Group and GroupEnd
- console.table();
- console.clear();
- console.debug();
It's used to print warning messages. It'll print a colored(yellow) warning message, commonly used to indicate that something is not quite right.
It's used to print error messages. It'll print a colored(red) error message, commonly used to indicate that something has gone wrong.
It's used to print the number of times it's called. It's useful to see how many times a function is called.
It's used to print an error message if the assertion fails. It's useful to check if some condition is true or not.
This method is used to start a timer to track the logs in the browser.
console.time(); method is used to start the timer and console.timeEnd(); to end the timer or to stop the timer.
And the console.timeLog(); is used to log the current value of the timer.
It's used to print a group of messages. It's useful to group messages together.
It's used to print tabular data. It'll help to visualize the data in a table format.
This console method is used to clear the messages from the console.
This method will clear all the previous logs.
This method outputs a message to the console with the log-level debug.
Introduction to CSS Part-2 PDF Click here to download
Easy Pickup
- 1. CSS More Samples
- 2. CSS Malayalam Classes
- 3. CSS Malayalam Notes