Skip to content

Instantly share code, notes, and snippets.

@JohnLouderback
Last active August 29, 2015 14:17
Show Gist options
  • Save JohnLouderback/eef18f3630d2911c5347 to your computer and use it in GitHub Desktop.
Save JohnLouderback/eef18f3630d2911c5347 to your computer and use it in GitHub Desktop.
Make the JS console "clear" function act the terminal "clear" command
(function(){
if (typeof clear !== 'undefined') {
var oldClear = clear;
Object.defineProperty(window, 'clear', {
get: function() {
oldClear();
return oldClear;
}
});
}
})();
// Now we can type "clear" instead of "clear()" in developer consoles.
@JohnLouderback
Copy link
Author

Now you can use either "clear()" or "clear" in the console to clear the console.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment