--- title: clear() slug: Web/API/Console/clear translation_of: Web/API/Console/clear ---
清空控制台.
控制台显示的内容将会被一些信息替换,比如‘Console was cleared’这样的信息。
需要的注意的一点是在Google Chrome浏览器中,如果用户在设置中勾选了“Preserve log”选项,console.clear()将不会起作用。
console.clear();
Specification | Status | Comment |
---|---|---|
{{SpecName("Console API", "#consoleclear", "console.clear()")}} | {{Spec2("Console API")}} | Initial definition |
{{CompatibilityTable}}
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Basic support | {{CompatVersionUnknown}} | {{CompatGeckoDesktop("48.0")}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} |
Available in workers | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
Feature | Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|
Basic support | {{CompatUnknown}} | {{CompatGeckoMobile("48.0")}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
Available in workers | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |