JavaScript Console Clear() Method

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.

JavaScript Console Clear() Method with Examples

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.

Registration Open – Microservices with ASP.NET Core Web API

New Batch Starts: 7th July 2025
Session Time: 6:30 AM – 8:00 AM IST

Advance your career with our expert-led, hands-on live training program. Get complete course details, the syllabus, registration, and Zoom credentials for demo sessions via the links below.

Contact: +91 70218 01173 (Call / WhatsApp)

Leave a Reply

Your email address will not be published. Required fields are marked *