Created
June 11, 2013 09:33
-
-
Save ghooghe/5755644 to your computer and use it in GitHub Desktop.
console.debug declaration to avoid javascript error problems
This file contains hidden or 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
| // Console declaration if not defined | |
| if (typeof console === 'undefined' || typeof console.debug === 'undefined') { | |
| console = {}; | |
| console.debug = function() {}; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There is a problem on this code: if console is not undefined and console.debug is undefined, so we will enter inside your if clause. But you do console = {} on line 3, so if console is not undefined, you will override de entire console object.