# no-computed-property-existence-check πŸ“ Disallow dynamic object property existence checks. πŸ’ΌπŸš« This rule is enabled in the βœ… `recommended` [config](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config). This rule is _disabled_ in the β˜‘οΈ `unopinionated` [config](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config). πŸ’‘ This rule is manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions). Dynamic property access and the [`in` operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/in) check inherited properties too. This can make values like `constructor` and `toString` look present even when the object does not define them. Use [`Object.hasOwn()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwn) when you need to check whether an object has its own property. Prefer `Map#has()` or `Set#has()` when the value is really a lookup table. ## Examples ```js // ❌ if (object[key]) {} // ❌ if (key in object) {} // βœ… if (object[key] === true) {} // βœ… if (Object.hasOwn(object, key)) {} ``` ```js // βœ… const value = object[key]; // βœ… if ('key' in object) {} // βœ… if (object['key']) {} ``` When type information is available and the property value is a known `boolean`, the access is a value read rather than an existence check, so it's allowed: ```ts declare const object: {a: boolean; b: boolean}; declare const key: 'a' | 'b'; // βœ… if (object[key]) {} ```