A javascript method is a property of an object that contains a function definition. A console method is an object used to access the browser debugging console. These console methods enable us to interact with a web page by executing JavaScript expressions in the contents of the page. With the help of these console methods, we can print messages, warnings, and errors to the browser console. That’ll be very helpful for debugging.
To see these console methods in action we need to get access to the developer console of the web browser. You can open the developer console of the chrome browser by right-clicking on the page that you want to get access to the developer console and then navigate to inspect and then navigate to the console window. Else, we can use the keyboard shortcut Ctrl + Shift + J (on Windows) or Ctrl + Command + J (on macOS)
You may also like to read: What is CGI? – explanation about the CGI-bin file
So let’s see 10 Javascript console methods that you should try.

1. Console.log
console.log() specifically is a method for developers to write code inconspicuously and inform the developers what the code is doing.
console.log("Hello, World!");
console.log(object);
console.log("hello", object1, object2);
2. Console.error
The error method writes an error message to the console. the console is useful for testing purposes. Syntax.
console.error(message);
3. Console.clear
The console.clear() method clears out the console if the environment allows it.
console.clear();
4. Console.dir
console.dir() is the way to see all the properties of a specified Javascript object in the console by which the developer can easily get the properties of the object.
console.dir();
5. Console.info
The console.info() method in HTML is used for writing a message in the console. It indicates an important message about any element or object.
console.info();
6. Console.table
console.table() method allows you to print out arrays and objects to the console in tabular form.
console.table();
7. Console.assert
The console.assert() method writes an error message to the console if the assertion is false. If the assertion is true, nothing happens.
console.assert();
8. Console.group and Console.groupend
The console.group() method creates a new inline group in the web console log, causing any subsequent console messages to be indented by an additional level until console.groupEnd() is called
console.group();
console.groupend();
9. Console.warn
Use console.warn() method to print warning message on browser console. It takes one argument of a message to be displayed.
console.warn("This is a warning!");
var object = {firstname: "Dasun", lastname: "Sucharith"};
console.warn(object);
10. Console.count and console.countreset
The console.count() method is to write a message on the console as the number of times it is called. By default, it labeled the message with “default”. But you can change the label by passing it an argument.
And you can use the console.countreset() method to reset the counter, So you can use this again further.
for (i = 0; i < 5: i++){
console.count();
}
for (i = 0; i < 5: i++){
console.count();
}
console.countreset();
11. Console.time, Console.timelog and Console.timeend
You can use console.time() method to start a timer to track how long an operation takes. And after starting the timer you can use the console.timeend() method to end the timer. You can also use the console.timelog() method to print the current time without starting or ending any timer.
console.time("Start timer");
console.timelog("current time");
console.timeend("end the timer");
Conclusion
These are the Javascript console methods that you use in your codes. Hope this post helps you to understand and know about javascript console methods.
Happy coding!!!
My website: dasunsucharith.github.io