Object.keys(): Why no inherited properties?
dmitry.soshnikov at gmail.com
Wed Sep 7 11:27:25 PDT 2011
On 07.09.2011 20:53, Brendan Eich wrote:
> On Sep 7, 2011, at 9:29 AM, Dmitry Soshnikov wrote:
>> On 07.09.2011 19:33, Felipe Gasper wrote:
>>> Why does Object.keys() not allow, as an option, iterating through inherited properties?
>> Because it's the same version that is from Prototype.js. I guess it was ported "as is" for compatibility with the library. But IMO, yes, native implementation could provide at least an option for this case (if needed).
> If you mean that an ES5-conforming implementation could add an optional boolean parameter to Object.keys, to get inherited enumerable properties too, then please, no: that is against the NOTE in Clause 15 (quoting from ES5.1):
No, I just explained from where the roots of Object.keys() -- from
Prototype.js. It was just ported "as is", though, IMO, when it was
porting, it with the same success could accept this additional
parameter. And I assumed that it was ported as is only because to
support compatibility with the Prototype.js.
> NOTE Implementations that add additional capabilities to the set of built-in functions are encouraged to do so by adding new functions rather than adding new parameters to existing functions.
> I think we should make this a normative restriction in ES6.
Yes, of course, I think it's way it should be.
More information about the es-discuss