I use Firebug\'s console.log() for debugging my website. If I try viewing my website in browsers without Firebug then I get a console is not defined er
Firebug source code provides a file to do this :
See firebugx.js
Do not reinvent the wheel every day :)
I don't think it gets much better than the workaround you link to. It's of course possible to melt it down to just defining console.log()
and leave off rest, but in essence, you won't get around a construct like this.
Only alternative that comes to mind is checking for console.log every time you call it, and that's even more cumbersome.
My final solution:
if(!("console" in window))
window.console = {log: function() {}};