How to fix ESLint error: Do not access Object.prototype method 'hasOwnProperty' from target object no-prototype-builtins | Our Code World

PHOTO EMBED

Sun Feb 13 2022 16:48:01 GMT+0000 (Coordinated Universal Time)

Saved by @arielvol #javascript

let events = {"some-index": false};
let key = "some-index";

if(Object.prototype.hasOwnProperty.call(events, key)) {
    // This would compile without any issue !
    console.log("The object has the property");
}
content_copyCOPY

https://ourcodeworld.com/articles/read/1425/how-to-fix-eslint-error-do-not-access-objectprototype-method-hasownproperty-from-target-object-no-prototype-builtins