Skip to content

Instantly share code, notes, and snippets.

@Melipone
Created February 15, 2011 16:01
Show Gist options
  • Save Melipone/827700 to your computer and use it in GitHub Desktop.
Save Melipone/827700 to your computer and use it in GitHub Desktop.
Javascript reflection
var test = function () {
function first () {
print ("first");
}
function second () {
print ("second");
}
};
// add a function to Object.prototype
Object.prototype.getOwnMethods = function(){
var memberArray = new Array();
for (var method in this) {
if (typeof this[method] == 'function' && this.hasOwnProperty(method)) {
memberArray.push(method);
};
};
return memberArray;
};
test.getOwnMethods();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment