views:

274

answers:

2

I install firebug and I'm done with my logs.

I test it in IE and of course I've got "undefined" error.

What's the common idiom to avoid this.

I don't really feel like commenting all the console.log statements in my file nor to mock it.

Well I'm not sure what to do.

A: 

What version of IE are you using?

You could try firebug lite, or IE's developer tools.

Nico Burns
The real problem is the final user won't have it, see?
OscarRyz
+3  A: 

i usually make a wrapper function like so:

function log(obj) {
    if (window.console && console.log) console.log(obj);
}

or you could do something like this at the beginning of your script file/element:

if (!window.console) { 
    window.console = {
        log: function(obj){ /* define own logging function here, or leave empty */ }
    };
}
Darko Z
And comment/uncomment that single line when debugging?
OscarRyz
Ahh no, it will return false on firefox+firebug :)
OscarRyz
you got it :) .........
Darko Z