Suggestion: "Object.hasOwnProperty"

Lewis Ellis lewis at shapesecurity.com
Thu May 26 20:33:48 UTC 2016


`Object.hasOwnProperty` already exists via the prototype chain, but I'm
guessing you wish it did something different.

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.

On Thu, May 26, 2016 at 12:26 PM, doodad-js Admin <doodadjs at gmail.com>
wrote:

> Hi,
>
>
>
> I think to create "Object.hasOwnProperty". Often, an object is used to
> store key/value pairs and most users forget that “hasOwnProperty” can be
> also be a key. Objects created by “Object.create(null)” don’t inherit this
> function and users get lost when they get such an object from a library or
> their own code.
>
>
>
> Claude Petit
>
>
>
> _______________________________________________
> 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/ff3c44d3/attachment-0001.html>


More information about the es-discuss mailing list