console:clear() 静态方法

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

console.clear() 方法会清空控制台,但前提是该控制台允许清空。像浏览器运行的图形控制台就允许清空,而像 Node 运行的终端上显示的控制台则不支持它,调用该方法将不会产生任何效果(也不会报错)。

语法

js
clear();

参数

返回值

无(undefined)。

规范

Specification
Console
# clear

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
clear() static method

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support