W3cubDocs

/Web APIs

console: clear() method

The console.clear() method clears the console if the console allows it. A graphical console, like those running on browsers, will allow it; a console displaying on the terminal, like the one running on Node, will not support it, and will have no effect (and no error).

Syntax

js

clear()

Parameters

None.

Return value

None (undefined).

Specifications

Specification
Console Standard
# clear

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
clear 25 12 39 8 12 7 4.4 25 39 12 7 1.5

© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/console/clear