Very handy console.log
method does exist in IE9, but for some obscure reason it's not a function. No, really
>> typeof console.log
"object"
So it cannot be .call
'ed or .apply
'ed or be set as callback to String.prototype.replace
. That's unfair.
This function wraps native console.log
method into a function so it becomes a function again. It does nothing with normal browsers and older ones. It takes no arguments and returns nothing.
See the 140byt.es site for a showcase of entries (built itself using 140-byte entries!), and follow @140bytes on Twitter.
To learn about byte-saving hacks for your own code, or to contribute what you've learned, head to the wiki.
140byt.es is brought to you by Jed Schmidt, with help from Alex Kloss. It was inspired by work from Thomas Fuchs and Dustin Diaz.
You're welcome. Maybe we could lose the try/catch?
function(){var a=this.console,b=a&&a.log,c=!b||b.call?0:a.log=function(){c.apply.call(b,a,arguments)}}
Tested in IE9 (haven't got older IEs handy at the moment).