1 /** Console X 2 * http://github.com/deadlyicon/consolex.js 3 * 4 * prevents console errors and makes IE console objects true functions 5 * 6 */ 7 (function() { 8 window.console || (window.console = {}); 9 10 var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml", 11 "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"]; 12 13 function emptyFunction(){} 14 15 for (var i = 0; i < names.length; ++i){ 16 window.console[names[i]] || (window.console[names[i]] = emptyFunction); 17 if (typeof window.console[names[i]] !== 'function') 18 window.console[names[i]] = (function(method) { 19 return function(){ return Function.prototype.apply.apply(method, [console,arguments]); }; 20 })(window.console[names[i]]); 21 } 22 })();