# in

[JS](https://lochiwei.gitbook.io/web/js) ⟩ [statement](https://lochiwei.gitbook.io/web/js/grammar/statement) ⟩ [expression](https://lochiwei.gitbook.io/web/js/grammar/statement/expr) ⟩ [operator](https://lochiwei.gitbook.io/web/js/grammar/op) ⟩ [relational](https://lochiwei.gitbook.io/web/js/grammar/op/relational) ⟩ 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](https://lochiwei.gitbook.io/web/js/grammar/op/table-of-operators "mention")
{% endhint %}

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

* :scales: [for-in-vs.-for-of-vs.-in](https://lochiwei.gitbook.io/web/js/grammar/statement/loop/for/for-in-vs.-for-of-vs.-in "mention")
  {% 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](https://lochiwei.gitbook.io/web/master/ref/javascript-the-definitive-guide "mention") ⟩ 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 %}
