Reflect.hasOwn() ?

Axel Rauschmayer axel at
Sat Jul 26 12:06:06 PDT 2014

On Jul 26, 2014, at 20:36 , Kevin Smith <zenparsing at> wrote:

> * As far as I can tell, `hasOwnProperty` is mainly used to implement maps via objects. `Map` will eliminate this use case.
> To a certain extent yes, but not completely.  Objects-as-maps will still be used quite frequently as object literals passed into functions (as an options object, for example).
> I think that there is still a need here.

Yes, but it’s much less urgent.

> Since we are really interested in *keys*, what about this:
>     Object.hasKey(obj, someKey);

Ah, good point! I hadn’t thought of symbols as property keys.

> which would be a more ergonomic and efficient way of saying:
>     Object.keys(obj).some(key => key === someKey)

Did you mean `Reflect.ownKeys()`? How about:

Reflect.ownKeys(obj).indexOf(someKey) >= 0

Or, maybe in ES7:


Dr. Axel Rauschmayer
axel at

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list