On Sunday, July 27, 2014, Tab Atkins Jr. <jackalm...@gmail.com> wrote:

> On Sat, Jul 26, 2014 at 11:36 AM, Kevin Smith <zenpars...@gmail.com
> <javascript:;>> 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).
>
> In that case, though, you don't want to use `hasOwnProperty`; you want
> to allow property bags to express properties on the proto (for
> example, as getters).  So this particular use-case of objects-as-maps
> is irrelevant for the question at hand.
>
> > 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)
>
> This is identical to `obj.key !== undefined`,


As long as "key" is enumerable.


Rick



> unless you're allowing
> undefined to be passed explicitly as a valid argument for some reason.




>
> ~TJ
> _______________________________________________
> es-discuss mailing list
> es-discuss@mozilla.org <javascript:;>
> https://mail.mozilla.org/listinfo/es-discuss
>
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to