loading...

Remove all console messages in just one line!

abhiprojectz profile image abhiprojectz ・1 min read

Welcome to abhi codes blog.

Ever wonder how to hide all the console messages in any text renderer in a very short span of time that's too quickly?

Then here is a PRO TIP!

Just use this one line of code!

console.log = function() {};

It will hide the console to open!

This command converts console function into an empty function resulting in "" empty string!

Try by yourself

More advanced way

You can create a function to hide the console at your convenience works even in IE<7

var logger = function()
{
    var oldConsoleLog = null;
    var pub = {};

    pub.enableLogger =  function enableLogger() 
                        {
                            if(oldConsoleLog == null)
                                return;

                            window['console']['log'] = oldConsoleLog;
                        };

    pub.disableLogger = function disableLogger()
                        {
                            oldConsoleLog = console.log;
                            window['console']['log'] = function() {};
                        };

    return pub;
}();

You can call the function as


 or

 ```disableLogger()```

 as per your project convenience!

Hope this small tip helps you!

*Happy coding!*

Posted on by:

abhiprojectz profile

abhiprojectz

@abhiprojectz

I'm a web and android developer.Basically reading in 12th grade.

Discussion

markdown guide
 

Here are some more approaches for those interested