Created
March 7, 2015 19:24
-
-
Save flowerains/0c935a5829557a0b1de5 to your computer and use it in GitHub Desktop.
console.js,看见的一个非常好的小插件,感谢作者"颜海镜"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;(function(g) { | |
'use strict'; | |
var _console = g.console || {}; | |
var methods = ['assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'exception', 'error', 'group', 'groupCollapsed', 'groupEnd', 'info', 'log', 'profile', 'profileEnd', 'table', 'time', 'timeEnd', 'timeStamp', 'trace', 'warn']; | |
var console = {version: '0.1.0'}; | |
var key; | |
for(var i = 0, len = methods.length; i < len; i++) { | |
key = methods[i]; | |
console[key] = function (key) { | |
return function () { | |
if (typeof _console[key] === 'undefined') { | |
return 0; | |
} | |
Function.prototype.apply.call(_console[key], _console, arguments); | |
}; | |
}(key); | |
} | |
g.console = console; | |
}(window)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment