Last active
August 15, 2016 08:36
-
-
Save r38y/6312262 to your computer and use it in GitHub Desktop.
Make console.log bulletproof.
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
// see if the browser supports console.log - fail gracefully if it doesn't | |
try { | |
console.log(); | |
console.debug(); | |
console.assert(); | |
} catch(e) { | |
console = { | |
log: function() {}, | |
debug: function() {}, | |
assert: function() {} | |
} | |
} |
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
try | |
console.assert(1) | |
catch error | |
console = | |
log: -> {} | |
assert: -> | |
debug: -> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment