On Jul 26, 2014, at 20:36 , Kevin Smith <zenpars...@gmail.com> 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:

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

Or, maybe in ES7:

```js
Reflect.ownKeys(obj).contains(someKey)
```

-- 
Dr. Axel Rauschmayer
a...@rauschma.de
rauschma.de



_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to