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.
Proposed:
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.
Dmitry.
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss