---
description: 🚧 施工中
---

# Generator

[JS](..) ⟩ [iteration]() ⟩ [generator function](generator/func) ⟩ Generator

{% hint style="success" %}
an [iterable](iterator/iterable "mention") returned by [func](generator/func "mention").
{% endhint %}

{% tabs %}
{% tab title="🔴 主題" %}
* <mark style="color:yellow;">**methods of**</mark>**&#x20;**<mark style="color:purple;">**generators**</mark>
  * [next](iterator/next "mention")
  * [return](iterator/return "mention")
  * 🚧 throw()
* [examples](generator/examples "mention")
  * [list](generator/examples/list "mention") - finite arithmetic sequence of integers
  * [closedrange](generator/examples/closedrange "mention") - closed range of integers
  * [integers](generator/examples/integers "mention") - infinite integer sequence
  * [fibonacci](generator/examples/fibonacci "mention") - infinite fibonacci seqence
{% endtab %}

{% tab title="⭐️ 重點" %}
{% hint style="info" %}
a <mark style="color:yellow;">**generator object**</mark> in JS is like a <mark style="color:orange;">**sequence**</mark> in Swift with <mark style="color:blue;">**Self == Self.Iterator**</mark> constraint.
{% endhint %}
{% endtab %}

{% tab title="👥 相關" %}
* generators are [iterable](iterator/iterable "mention")s (i.e. [iterable](iterable "mention") and [iterator](iterator "mention")s.)
{% endtab %}

{% tab title="📗 參考" %}
* [x] JS.info ⟩ [Generators](https://javascript.info/generators)
* [x] [認識 JavaScript Iterable 和 Iterator](https://jiepeng.me/2018/04/19/iterable-and-iterator-in-javascript)
* [ ] JavaScript: The Definitive Guide ⟩ 12. Iterators and Generators
{% endtab %}

{% tab title="📘 手冊" %}
* [ ] [Generator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator)
* [ ] [Iterators and generators](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Iterators_and_Generators)
{% endtab %}
{% endtabs %}

##
