Created
April 1, 2011 19:31
-
-
Save moudy/898712 to your computer and use it in GitHub Desktop.
handy code for monitoring global vars, should go at the end
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
if (true /* MONITOR_GLOBALS */) { | |
(function(){ | |
var globals = {}; | |
var startGlobals = []; | |
for (var j in window) { | |
globals[j] = true; | |
startGlobals.push(j); | |
} | |
if (true /* PRINT_INITIAL_GLOBALS */) | |
console.log("Initial globals: "+startGlobals.sort().join(', ')); | |
setInterval(function() { | |
var newGlobals = []; | |
for (var j in window) { | |
if (!globals[j]) { | |
globals[j] = true; | |
newGlobals.push(j); | |
} | |
} | |
if (newGlobals.length > 0) | |
console.log("NEW GLOBALS: "+newGlobals.sort().join(', ')); | |
}, 1000); | |
})(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment