Back to: JavaScript Tutorial For Beginners and Professionals
JavaScript Console Clear() Method
In this article, I am going to discuss JavaScript Console Clear() Method with Examples. Please read our previous article where we discussed JavaScript Console Assert() Method with Examples.
JavaScript console.clear() Method
After logging so much into the console. We would need to clear it up for further use. For that Console.Clear() method is used. The Console.Clear() method is used to clear the console history. In other words, this method removes previously printed messages. After clearing the console this method writes “Console was cleared” in the console.
Syntax: console.clear()
What we discussed above is given in the below example.
Example to Understand JavaScript Console Clear() method
<html> <head> <title>JavaScript console clear() method example</title> </head> <body> <script> console.log("JavaScript Console clear method demo.") console.clear(); </script> </body> </html>
Output: Run the above code, and then press the F12 key and go to the Console tab as shown in the below image.
In the next article, I am going to discuss JavaScript Console Count() Method with Examples. Here, in this article, I try to explain JavaScript Console Clear() Method with Examples. I hope this article will help you with your need. I would like to have your feedback. Please post your feedback, question, or comments about this article.