Last active
December 24, 2015 16:09
-
-
Save CezaryDanielNowak/6825846 to your computer and use it in GitHub Desktop.
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
// Make it safe to do console.log() always. | |
(function (c) { | |
var method, | |
d = function() {}, | |
m = 'assert,count,debug,dir,dirxml,error,exception,group,groupCollapsed,\ | |
groupEnd,info,log,markTimeline,profile,profileEnd,time,timeEnd,trace,warn' | |
.split(','); | |
while (method = m.pop()) { | |
c[method] || (c[method] = d); | |
} | |
})(window.console || (window.console = {})); | |
// And the same in CoffeeScript: | |
/* | |
do (cons = (window.console ||= {})) -> | |
noop = -> | |
methods = "assert,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,markTimeline,profile,profileEnd,time,timeEnd,trace,warn".split(",") | |
cons[method] ||= noop while method = methods.pop() | |
return | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment