Is it possible to get all of the functions in a JavaScript object?
Consider the following object:
var myObject =
{
method: function ()
{
this.nestedMethod = function ()
{
}
},
anotherMethod: function() { }
});
If I pass it into the function below I will get this result:
method
anotherMethod
(function to get all function names)
function properties(obj)
{
var output = "";
for (var prop in obj) {
output += prop + "<br />";
try
{
properties(obj[prop]);
}
catch(e){}
}
return output;
}
How can I make this output:
method
nestedMethod
anothermethod
method.$.getJSON("...", function(result) { self[result.name] = function() { ... })