Skip to content

Instantly share code, notes, and snippets.

@CezaryDanielNowak
Last active December 24, 2015 16:09
Show Gist options
  • Save CezaryDanielNowak/6825846 to your computer and use it in GitHub Desktop.
Save CezaryDanielNowak/6825846 to your computer and use it in GitHub Desktop.
// 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