Today, it is very common to write code like this:
const hasOwnProperty = Object.prototype.hasOwnProperty;
if (hasOwnProperty.call(object, 'foo')) {
}
Or to use libraries that expose a simple version of Object.prototype.hasOwnProperty, such as has or lodash.has.
With the Object.hasOwn proposal, we can simply write:
if (Object.hasOwn(object, 'foo')) {
}
Object.hasOwn is already available in V8 v9.3 behind the --harmony-object-has-own flag, and we’ll be rolling it out in Chrome soon.
Object.hasOwn support #