Suggestion: "Object.hasOwnProperty"

doodad-js Admin doodadjs at
Thu May 26 20:38:49 UTC 2016

>> 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 `{}, somePropertyName)` pattern.


Yeah, sure. But it could be cleaner to do:

Object.hasOwnProperty(myObj, someName)

instead of

{}, someName)

More information about the es-discuss mailing list