Suggestion: "Object.hasOwnProperty"

Michał Wadas michalwadas at gmail.com
Thu May 26 21:34:09 UTC 2016


This would break a Web, a I have seen code that relies on
Object.hasOwnProperty === Object.prototype.hasOwnProperty

Anyway, it would be handy to have such function as `Reflect.hasOwn` or
something like that.
On 26 May 2016 10:38 p.m., "doodad-js Admin" <doodadjs at gmail.com> wrote:

> >> Both the concern of `someObj.hasOwnProperty(somePropertyName)`
> attempting to call the `hasOwnProperty` property of `someObj` rather than
> walking the prototype chain to get `Object.prototype.hasOwnProperty`, and
> the >> concern of `someObj` having a null prototype (or otherwise not
> having `Object.prototype.hasOwnProperty` on its prototype chain) can be
> avoided with the `{}.hasOwnProperty.call(someObj, somePropertyName)`
> pattern.
>
> Hi,
>
> Yeah, sure. But it could be cleaner to do:
>
> ```js
> Object.hasOwnProperty(myObj, someName)
> ```
>
> instead of
>
> ```js
> {}.hasOwnProperty.call(myObj, someName)
> ```
>
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20160526/4841e6f6/attachment.html>


More information about the es-discuss mailing list