How to disable console.log in JavaScript

How to disable console.log in JavaScript

Sometimes you might want to disable console.log in JavaScript, because, say, you have a library performing excessive logging, or for any other reason. This is how you can do it:

console.log = function () {};

In case you want to preserve the console.log functionality under a different function, you can do it like this:

consoleLog = console.log;
console.log = function () {};

Subscribe to Asad Dhamani

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
[email protected]
Subscribe