Skip to content

Instantly share code, notes, and snippets.

@fredyang
Created December 20, 2011 20:35
Show Gist options
  • Save fredyang/1503158 to your computer and use it in GitHub Desktop.
Save fredyang/1503158 to your computer and use it in GitHub Desktop.
display how many global variable is used by user (not system)
(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;
}
})();
@fredyang
Copy link
Author

put this script before all script, press f12 for debugger, and type console.userGlobal() to display all the global variables.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment