Friday, April 20, 2012

console.log for all browsers...

Just a line of JavaScript that allows me lo leave my 'console.log' lines while doing cross-browser development:

var console = console || { log: function() {} };

'console' is supported in Chrome and IE9 (and some others...) but not in IE6 that chokes on it. The line above just executes a 'null' console.log when console is not supported and lets me keep all the 'console.log' lines while I am developing my code.