console.log not working in Internet Explorer

I am doing a lot of javascript coding nowadays with knockout.js and jQuery. Working in Firefox and Firebug make you forget all those nasty habits of Internet Explorer, until the releasedate is coming closer. ho ho! This was one nasty ”thing” that I had forgotten. Console.log is only available in ”debug mode” (hit F12) in Internet Explorer. If you are calling console.log in ”standard mode” your webpage breaks.

One solution is to remove all logging and another one is to follow ”Mister Lucky’s” comment at stackoverflow and declare console.log like this:

if (!('console' in this)) console={};
'log info warn error dir clear'.replace(/\w+/g,function(f) {
if (!(f in console)) console[f]=console.log||new Function;

Now I never forget this silly one…


E-postadressen publiceras inte. Obligatoriska fält är märkta *