Clear all messages of console in browser in JS -- clear | JS

Introduction

The console.clear() method can clear all messages from console.log()

NOTICE

It will take effect on graphical browser.

Otherwise (such as in DOS terminal), it may have no effect and NOT cause error.

Example

Example 1

Code



    
        
    

Output

Example 2

Code

console.log("1");
console.log("2");
console.clear();
console.log("3");

Output

Clear all messages of console in browser in JS -- clear | JS_第1张图片

 

Reference

console: clear() method - Web APIs | MDN (mozilla.org)

你可能感兴趣的:(javascript,前端,开发语言)