Skip to content

Instantly share code, notes, and snippets.

@tofumatt
Created June 14, 2011 15:07
Show Gist options
  • Save tofumatt/1025079 to your computer and use it in GitHub Desktop.
Save tofumatt/1025079 to your computer and use it in GitHub Desktop.
Console.log
// Try to use console.log(). If it's undefined, define an
// empty object/static method to allow console.log() use
// throughout the app without breaking anything.
try {
console.log("Testing console.log()");
} catch (e) {
// Prevent errors arising from use of console.log()
console = {
log: function(a, b) {
// Don't do anything, just define this so we can
// use console.log() without worrying about undefined
// when the console log isn't open.
}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment