Object.hasOwnProperty() yields the ESLint ‘no-prototype-builtins’ error: how to fix?
You can access it via Object.prototype: Object.prototype.hasOwnProperty.call(obj, prop); That should be safer, because Not all objects inherit from Object.prototype Even for objects which inherit from Object.prototype, the hasOwnProperty method could be shadowed by something else. Of course, the code above assumes that The global Object has not been shadowed or redefined The native Object.prototype.hasOwnProperty has … Read more