Enumerability

Allen Wirfs-Brock allen at wirfs-brock.com
Mon Jan 13 07:53:51 PST 2014


On Jan 13, 2014, at 6:46 AM, Boris Zbarsky wrote:

> On 1/12/14 11:57 PM, Andrea Giammarchi wrote:
>> Recap: it seems we agree classes properties and methods should not show
>> up in a for/in
> 
> I should note that web developers commonly expect DOM methods/properties to show up in for/in (and in fact often write code depending on that, sometimes depending on the order of the enumeration).  So to the extent that we're trying to align DOM stuff with ES6 classes, we may need a class-level switch to decide whether a particular class has enumerable members or something.  :(

Whatever the default enumerability, you can always change it using Object.defineProperty and you can write a utility function that will does. Define the utility as a method on function prototype and you can say something like:

class Foo {};
Foo.enumerableMethods();
//or
Foo.nonenumerableMethods();

Allen



More information about the es-discuss mailing list