clear javascript console in Google Chrome
Update: console.clear()
is available in all browsers
Update: As of November 6, 2012, console.clear()
is now available in Chrome Canary.
If you type
clear()
into the console it clears it.I don't think there is a way to programmatically do it, as it could be misused. (console is cleared by some web page, end user can't access error information)
one possible workaround:
in the console type window.clear = clear
, then you'll be able to use clear in any script on your page.
Chrome console clear assignment and variables
Easiest way to clear data from the console is to refresh the page.
What you are affecting when declaring any variables or functions within the developer console is the global execution context, which for web browsers is window
.
When you clear()
the console you are telling Chrome to remove all visible history of these operations, not clear the objects that you have attached to window
.
how do I clear google chrome console suggessions
[EDIT] As of Chrome 50, you can use "Clear console history" from the console context menu.
The situation seems to be a bit unlikely to happen (confident information in the devtools console?), but I've found the problem of clearing command history interesting. Especially, when it turned out that nothing from the
'Settings'->'Clear browsing data...'
clears it. Closing the tab or restarting the browser doesn't help either.First, I've opened DevTools (A) in a separate window:
Then, knowing that DevTools are in fact a webapp, I've opened another DevTools window (B) inside already opened one (A) using keyboard shortcut. Next, I've navigated to the "Resoures" tab, and in the "Local storage" section found a consoleHistory
entry.
After removing it (right-click and "Delete") and closing both DevTools windows (A and B) I found my console history empty.
How to clear console history
If you want to clear the list of last typed commands, follow these steps:
(Step 1 and 2 are important, don't skip them!)
- Undock the console (click on the icon in the bottom-left corner, ).
(if you don't see , but , then hold the mouse pressed for a few seconds to get the desired icon) - Press Ctrl + Shift + J to open the console for this console. (On OSX use Cmd + Option + i)
- Go to the Resources tab, "Local Storage",
chrome-devtools://devtools
. Right-click on the item with key "consoleHistory", and choose "Delete".
Done! You may close the new console, and then dock the previous one if wanted. The console history will be gone when you reload the console.
You could also use Incognito mode if you don't want to keep the list of commands you're going to type.
How to clear Chrome console by shortcut keys?
You can use Ctrl + L to clear the chrome-dev-console on Windows/Linux and Cmd + K on Mac.
Related Topics
How to Randomly Generate HTML Hex Color Codes Using JavaScript
JavaScript Add Method to Object
How Does Internationalization Work in JavaScript
How to Send Email by Using JavaScript or Jquery
JavaScript Displaying a Float to 2 Decimal Places
Can Jquery Read/Write Cookies to a Browser
Check If Element Is Visible on Screen
How to Invoke "Click" Event Programmatically in D3
Merge Duplicate Objects in Array of Objects
Rotate Object on Specific Axis Anywhere in Three.Js - Including Outside of Mesh
How to Sort an Associative Array by Its Values in JavaScript
Ecmascript 2015: Const in for Loops
Understanding JavaScript Immutable Variable
Check If an Object Implements an Interface at Runtime with Typescript
How to Create a Date Object from String in JavaScript
Mousewheel Event in Modern Browsers
How to Show a Spinner While Loading an Image via JavaScript
How to Pull the File Name from a Url Using JavaScript/Jquery