Skip to content

Instantly share code, notes, and snippets.

@mdix
Created December 7, 2011 07:09
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 mdix/1441816 to your computer and use it in GitHub Desktop.
Save mdix/1441816 to your computer and use it in GitHub Desktop.
Method that returns all Methods it can find on a given object
function getMethods(obj) {
var result = [];
var positionOfBrace = null;
var functionAndParams = '';
var functionAsString = '';
for (var id in obj) {
try {
if (typeof(obj[id]) == "function") {
functionAsString = obj[id].toString();
positionOfBrace = functionAsString.indexOf('{');
functionAndParams = functionAsString.slice(0, positionOfBrace);
result.push(id + ": " + functionAndParams + "{ [code] }\n");
}
} catch (err) {
result.push(id + ": FAIL");
}
}
return result;
}
@mdix
Copy link
Author

mdix commented Dec 7, 2011

You can just paste that in your browsers console (webdevelopper toolbar, firebug etc.) and run it by passing it a object, like: getMethods(object);

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