Dmitry A. Soshnikov dmitry.soshnikov at gmail.com
Sun Aug 7 12:36:15 PDT 2011

Hi again,

I'm about to propose `Object.methods(obj)` meta-method (or 
`Object.getMethods(obj)`). Unfortunately naming convention is 
inconsistent (arrgh!) -- `Object.keys` (hello, Ruby and Prototype.js) 
vs. Object.getOwnPropertyNames (o_O hello Java), so the method name can 
be chosen later.

But the idea is to get the properties (or their names) which are methods 
on the object.


var foo = {
   bar: function () {},
   __proto__: {baz: function () {}}

- Object.getMethods(foo) -> {bar: function () {}, baz: function () {}}

- Object.getOwnMethod(foo) -> {bar: function () {}}

- Object.getMethodNames(foo) -> ["bar", "baz"]

- Object.getOwnMethodNames(foo) -> ["bar"]

Of course it can be easily implemented in JS itself just filtering the 
Object.getMySummerVacationWasLongOwnPropertyNames or Object.keys(...), 
but directly in the engine it will be more efficient.


More information about the es-discuss mailing list