Skip to content

Instantly share code, notes, and snippets.

@mdix mdix/getMethods.js
Created Dec 7, 2011

Embed
What would you like to do?
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

This comment has been minimized.

Copy link
Owner 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
You can’t perform that action at this time.