I am learning JavaScript and have been doing a lot of testing in the Chrome console. Even if I clear the console, or use any of the commands I've seen in other threads (localStorage.clear()
) any variables I've assigned still show up.
For example, if I do something like var name = "Bob";
I clear and close the console, reopen it, and look for the value of name
, it's still Bob
.
What's the best way to clear these out?
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
.