clear()

非标准

该特性是非标准的,请尽量不要在生产环境中使用它!

清空控制台.

控制台显示的内容将会被一些信息替换,比如‘Console was cleared’这样的信息。

需要的注意的一点是在Google Chrome浏览器中,如果用户在设置中勾选了“Preserve log”选项,console.clear()将不会起作用。 

语法

console.clear();

规范

Specification Status Comment
Console API
console.clear()
Living Standard Initial definition

浏览器兼容性

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help! (en-US)

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support (Yes) 48.0 (48.0) (Yes) (Yes) (Yes)
Available in workers ? ? ? ? ?
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support ? 48.0 (48.0) ? ? ?
Available in workers ? ? ? ? ?

相关链接