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

Felipe Gasper felipe at felipegasper.com
Wed Sep 7 09:11:41 PDT 2011


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?

-FG


More information about the es-discuss mailing list