Skip to content

Instantly share code, notes, and snippets.

@gentlefox
Forked from Jpunt/console-fallback.js
Created March 25, 2014 05:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gentlefox/9755686 to your computer and use it in GitHub Desktop.
Save gentlefox/9755686 to your computer and use it in GitHub Desktop.
// This is not some kind of polyfill! It's just to prevent old browsers from failing horribly
var fallback = function() {};
var methods = ['assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'error', 'group', 'groupCollapsed', 'groupEnd', 'info', 'log', 'profile', 'profileEnd', 'time', 'timeEnd', 'timeStamp', 'trace', 'warn', 'table'];
if(typeof console === 'undefined') {
var console = {};
}
for(var i in methods) {
if(typeof console[methods[i]] === 'undefined') {
console[methods[i]] = fallback;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment