Reflect.hasOwn() ?

Kevin Smith zenparsing at
Sat Jul 26 11:36:51 PDT 2014

> * 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.  Since we are really interested in
*keys*, what about this:

    Object.hasKey(obj, someKey);

which would be a more ergonomic and efficient way of saying:

    Object.keys(obj).some(key => key === someKey)

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

More information about the es-discuss mailing list