Simple console.log wrapper hangs IE10 and Chrome
by Ondrej Medek
JavaScript
/** Simple console.log wrapper hangs IE10 and Chrome
When you assing console.log to own variable, then IE10 and Chrome hangs.
Strange ehaviour of IE10 is when the the developer tools F12 are open, it proceeds OK.
Use a wrapper function _log to correctly wrap console.log.
*/
var mylog = {
log : this._logNull,
init: function() {
if (typeof console == 'object' && typeof console.log == 'function') {
console.log(this);
this.log = console.log; // IE10 hangs
//this.log = this._log; // IE10 ok
}
},
_logNull : function() {},
_log : function() { console.log.apply(console, arguments); }
};
mylog.init();
mylog.log('Hello');
alert('proceeded');