> 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/iterator/make-iterable.md).

# make iterator iterable

[JS](/web/js.md)⟩ [iteration](/web/js/iteration.md) ⟩ [iterator](/web/js/iteration/iterator.md) ⟩ make iterator iterable

{% hint style="success" %}
an [iterator](/web/js/iteration/iterator.md) can be made [iterable](/web/js/iteration/iterable.md) by making it <mark style="color:yellow;">**return itself**</mark> in the [make-iterator method](/web/js/iteration/iterable/make-iterator-method.md).
{% endhint %}

{% tabs %}
{% tab title="💈範例" %}

```javascript
const iterator = {

  // ⭐️ iterator must have `next()` method
  next() {
    // return iteration result ...
  },
  
  // ⭐️ iterable must have "make iterator" method
  [Symbol.iterator] () { 
      // because `iterator` is itself an iterator,
      // we can simply return itself. ⭐️ 
      return this;
  },
  
};
```

{% endtab %}

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

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