Is there a method or propertie to get all methods from an object? For example:
function foo() {}
foo.prototype.a = function() {}
foo.prototype.b = function() {}
foo.get_methods(); // returns ['a', 'b'];
UPDATE: Are there any method like that in Jquery?
Thank you.
Remember that technically javascript objects don't have methods. They have properties, some of which may be function objects. That means that you can enumerate the methods in an object just like you can enumerate the properties. This (or something close to this) should work:
There are complications to this because some properties of objects aren't enumerable so you won't be able to find every function on the object.
I'm on a phone with no semi colons :) but that is the general idea.
for me, the only reliable way to get the methods of the final extending class, was to do like this:
Get the Method Names:
Or, Get the Methods:
In ES6:
the best way is:
use 'let' only in es6, use 'var' instead