On 9/7/11 11:17 AM, David Bruant wrote:
Le 07/09/2011 18:11, Felipe Gasper a écrit :
On 9/7/11 11:08 AM, David Bruant wrote:
Le 07/09/2011 17:33, Felipe Gasper a écrit :
Why does Object.keys() not allow, as an option, iterating through
inherited properties?
I do not have the answer to this very question.
However, if you want to iterate through all (own and inherited)
enumerable properties, you can use a for-in loop.
Right, but for that matter, if you want Object.keys, you can just
write out a for-in loop as well and just do .hasOwnProperty().
Object.keys must be considered a convenience method; it just seems
like there are lots of reasonable scenarios of wanting the inherited
properties as well as the object’s own.
Object.allKeys(), anyone?
Object.getPropertyNames from
http://wiki.ecmascript.org/doku.php?id=harmony:extended_object_api ?
Or do you want to filter out non-enumerable properties?
Yes. ISTM there’s a legitimate case for putting a key-lister function
that includes all inherited, non-enumerable properties.
-F
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss