Enumerability

Allen Wirfs-Brock allen at wirfs-brock.com
Sat Jan 11 09:39:31 PST 2014


On Jan 11, 2014, at 9:24 AM, Andrea Giammarchi wrote:

> I would like to see some Rick or David example about the "expected to be enumerable".
> 
> If that's about knowing if a class is native or not, looping with a for/in its prototype or any instance does not seem to mean anything reliable since even native methods can be redefined and made enumerable.

It's not just prototypes.  The same non-enumerability conventions are applied to built-in constructor properties (ie, class static methods).

> 
> If that's the case I would rather consider a simple `Object.isNative(generic)` proposal that would simply return true for all native things that would return `[native code]` via {}.toString.call(generic)

This has nothing to do with "native code".  Built-ins can be self hosted using JS code and show that code (or not) in their toString.  It's strictly a specification issue.  The spec. says that, in general, built-in methods are non-enumerable and that non=built-in methods are enumerable.


allen


More information about the es-discuss mailing list