Created
December 20, 2011 20:35
-
-
Save fredyang/1503158 to your computer and use it in GitHub Desktop.
display how many global variable is used by user (not system)
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
(function() { | |
var keys = []; | |
for (var k in window) { | |
keys.push(k); | |
} | |
function isUserGloba(k) { | |
for (var i = 0; i < keys.length; i++) { | |
if (keys[i] === k) { | |
return false; | |
} | |
} | |
return true; | |
} | |
console.userGlobal = function() { | |
var rtn = []; | |
for (var k in window) { | |
if (isUserGloba(k)) { | |
rtn.push(k); | |
} | |
} | |
return rtn; | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
put this script before all script, press f12 for debugger, and type console.userGlobal() to display all the global variables.