Q:

Can I create my own function with the same name as an existing to customize it? 

I have some console.log commands spread through my site. 
Is it possible to override console.log with my own function?   I want to customize the function so that it only logs if a specific variable is set to true. 
In the end, I would still need to call the real console.log from this function. 
Thanks
Kevin

A:

Just create a closure, and store the original console.log function in a local variable. 
Then override console.log, and call the original function after you do your check:
(function(){
    var original = console.log;

    console.log = function(){
        if ( log ) { // <-- some condition
            original.apply(this, arguments);
        }
    };
})();

Here's the fiddle: http://jsfiddle.net/J46w8/

