此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。

View in English Always switch to English

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 ⁨2015年7月⁩.

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

语法

js
clear();

参数

返回值

无(undefined)。

规范

Specification
Console
# clear

浏览器兼容性