Object.allKeys? WAS Re: Object.keys(): Why no inherited properties?

David Bruant david.bruant at labri.fr
Wed Sep 7 09:17:59 PDT 2011

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?


More information about the es-discuss mailing list