Skip to content

Instantly share code, notes, and snippets.

@asawilliams
Created July 7, 2011 15:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asawilliams/1069724 to your computer and use it in GitHub Desktop.
Save asawilliams/1069724 to your computer and use it in GitHub Desktop.
Finds all the global functions and variables. Tries to not count the native browser functions and variables but does not catch all of them
var numf=0; var nump=0;
for(var p in this) {
if(typeof(this[p]) == "function" && this[p].toString().indexOf('[native code]') === -1 ){
numf+=1;
console.log(p+"()");
} else if(typeof this[p] != 'undefined' && this[p] && this[p].toString().indexOf('[native code]') === -1){
var cont = false;
if(typeof this[p] === 'object') {
for(op in this[p]) {
if(p[op] && p[op].toString().indexOf('[native code]') === -1){
cont = true;
break;
}
}
}
if(cont) continue;
nump+=1;
console.log(p);
}
}
console.log("functions: "+numf+" properties: "+nump);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment