背景
在项目中如果有写console.log(),IE9以下浏览器没打开F12调试模式(IE Dev Tools)的时候,程序执行到那里就停止继续往下执行。但是当我们F12打开调试模式的时候,之前做过console输出日志的操作会继续
// IE9里console的处理
// console.log && console.warn && console.error
(function () {
var method
var noop = function () {}
var methods = [
'assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'error',
'exception', 'group', 'groupCollapsed', 'groupEnd', 'info', 'log',
'markTimeline', 'profile', 'profileEnd', 'table', 'time', 'timeEnd',
'timeline', 'timelineEnd', 'timeStamp', 'trace', 'warn'
]
var length = methods.length
var console = (window.console = window.console || {})
while (length--) {
method = methods[length]
if (!console[method]) {
console[method] = noop
}
}
}())