Created
February 15, 2011 16:01
-
-
Save Melipone/827700 to your computer and use it in GitHub Desktop.
Javascript reflection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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