> For the complete documentation index, see [llms.txt](https://lochiwei.gitbook.io/web/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lochiwei.gitbook.io/web/js/grammar/op/relational/in.md).

# in

\`prop in obj\`

[JS](/web/js.md) ⟩ [statement](/web/js/grammar/statement.md) ⟩ [expression](/web/js/grammar/statement/expr.md) ⟩ [operator](/web/js/grammar/op.md) ⟩ [relational](/web/js/grammar/op/relational.md) ⟩ in

{% hint style="success" %}

```javascript
// ⭐️ check if `prop` is property of `obj` (including inherited)
prop in obj        // ⭐️ prop: string-convertable expression
```

:star2: [table of operators](/web/js/grammar/op/table-of-operators.md)
{% endhint %}

{% tabs %}
{% tab title="👥 相關" %}

* :scales: [for-in vs. for-of vs. in](/web/js/grammar/statement/loop/for/for-in-vs.-for-of-vs.-in.md)
  {% endtab %}

{% tab title="💈範例" %}
replit： ["in" operator](https://replit.com/@pegasusroe/the-in-operator#index.js)

```javascript
let point = {x: 1, y: 2};
let array = [1, 2, 3];

'x' in point,            // true
'z' in point,            // false
'toString' in point,     // true    (inherited)

'0' in array,            // true
1 in array,              // true    (1 -> '1')
3 in array,              // false   (3 -> '3', no such prop)
'toString' in array,     // true    (inherited)
```

{% endtab %}

{% tab title="📗 參考" %}

* [ ] [JavaScript: The Definitive Guide](/web/master/ref/javascript-the-definitive-guide.md) ⟩ 4.9.3 The in Operator
  {% endtab %}

{% tab title="📘 手冊" %}

* [in operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/in)
  {% endtab %}
  {% endtabs %}
