JSFiddle - React, Tailwind, and code Playground

JavaScript

// Avoid global functions via a self calling anonymous one
// (it uses jQuery)
(function(MYAPP, $, undefined) {
    // Prevent errors in browsers without console.log
    if (!window.console) window.console = {};
    if (!window.console.log) window.console.log = function(){};

    //Private var
    var console_log = console.log;  

    //Public methods
    MYAPP.enableLog = function enableLogger() {
                            console.log = console_log;
                      };

    MYAPP.disableLog = function disableLogger() {
                            console.log = function() {};
                       };
}(window.MYAPP = window.MYAPP || {}, jQuery));


// Example Usage:
$(function() {    
    MYAPP.disableLog();    
    console.log('this should not show');

    MYAPP.enableLog();
    console.log('This will show');
});