Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get all instance methods of a CoffeeScript object

I have a CoffeeScript object and I want to get all of its instance methods.

Is there an easy way to do this?

like image 819
ajsie Avatar asked Nov 20 '11 18:11

ajsie


1 Answers

You can get all of the instance methods as they are now using the following CoffeeScript code:

keys = (k for k, v of obj when typeof v is 'function')

@thejh's solution will give you more than just functions and doesn't work in all JS platforms, but is otherwise correct. Also note that a CoffeeScript object is a JavaScript object -- there's no distinction, really.

like image 106
Brian Donovan Avatar answered Sep 21 '22 09:09

Brian Donovan