> 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/iteration/iterable+ext/isiterable.md).

# obj.isIterable

[JS](/web/js.md)⟩ [iteration](/web/js/iteration.md) ⟩ [iterable](/web/js/iteration/iterable.md) ⟩ [extension](/web/js/iteration/iterable+ext.md) ⟩ obj.isIterable

{% hint style="success" %}
check if an <mark style="color:yellow;">**object**</mark> is [**iterable**](/web/js/iteration/iterable.md).

```javascript
array.isIterable,    // true
object.isIterable,   // false
(3).isIterable,      // false
```

{% endhint %}

{% tabs %}
{% tab title="💾 程式" %}

* replit ⟩ [Iterable (protocol)](https://replit.com/@pegasusroe/Iterable-protocol#ext/Iterable.js)&#x20;

```javascript
Object.defineProperties(Object.prototype, {
    // ⭐️ obj.isIterable
    isIterable: {
        get() {
            // ⭐️ code copied from the chat bot "chatGPT"
            return typeof this[Symbol.iterator] === 'function';
        }
    },
}
```

{% endtab %}

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

* [Symbol.iterator](/web/js/val/prim/symbol/iterator.md) - "make-iterator" method name.
* [Object.defineProperty()](/web/js/val/obj/prop/create/object.defineproperty.md) - define new properties.
  {% endtab %}

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

* [ ] [JavaScript: The Definitive Guide](/web/master/ref/javascript-the-definitive-guide.md) ⟩ 12.2 Implementing Iterable Objects&#x20;
  {% endtab %}
  {% endtabs %}
