console method clear() in Javascript
The console method clear() used to clear the console and it writes message Console was cleared on console.
Syntax
 1 console.clear()
Console method clear()
 1 <!DOCTYPE html>
 2 <html>
 3 <body>
 4 
 5 	<h1>The Console Object</h1>
 6 	<h2>The assert() Method</h2>
 7 	<p>The console clear after 1 second</p>
 8 
 9 	<script>
 10 	  console.log("The console clear after 1 second");
 11 	  setTimeout(()=> {
 12 	    console.clear();
 13 	  }, 1000);
 14 	</script>
 15 </body>
 16 </html>
In the above example, a document is created with elements including script element. A script element prints message on console. A method setTimeout() calls callback function after 2 second, that clear the console with prints message Console was cleared.
Console method clear()
Privacy Policy
Terms of Service
Disclaimer
Contact us
About us