Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Given an arbitrary javascript object, how can i find its methods?

I know this is possible in python, but can i get a list of methods for a javascript object?

like image 232
telaviv Avatar asked Jul 15 '10 04:07

telaviv


1 Answers

You can loop over the properties in the object and test their type.

for(var prop in whatever) {
    if(typeof whatever[prop] == 'function') {
        //do something
    }
}
like image 114
Jani Hartikainen Avatar answered Sep 22 '22 07:09

Jani Hartikainen