Object.methods

Dmitry A. Soshnikov dmitry.soshnikov at gmail.com
Tue Aug 9 14:05:32 PDT 2011


On 24.08.2011 0:39, Allen Wirfs-Brock wrote:
>
> On Aug 9, 2011, at 1:03 PM, Dmitry A. Soshnikov wrote:
>>
>> And what about this method Object.getMethods(...), 
>> Object.getMethodNames(...). Do we need it? I think it can be useful 
>> (since methods can be non-enumerable, and Object.keys(...) won't 
>> help, and after Object.getOwnPropertyNames(...) you have to manually 
>> filter them when `typeof` is "function")
>>
>
> I'm don't really see the that they are needed enough to build these in 
> when they can be synthesized pretty easily.  What is the justification 
> for these and not others such as getAccessorProperties, 
> getDataProperties, getNonWritableProperties, etc.
>

Maybe, why not? `Object.methods` is just standard in some languages 
(e.g. Ruby, `foo.instance_methods`). Yes, all of yours listed above 
could be either built-in or self-implemented, don't know how often they 
are needed IRL. This topic follows the recent near topic with 
doc-comments of functions. The same, playing with a new language in 
console it's the best just to type e.g. `foo.methods` (like in Ruby) and 
to see directly the list of methods to which the object responds. 
Besides, perhaps they can be used in other meta-level programming, but 
the initial idea seems studying the language in the console and playing 
with objects (not sure though whether it's a sound reason to be accepted 
for standardization).

Dmitry.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20110810/6a2e71ad/attachment-0001.html>


More information about the es-discuss mailing list