> 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/statement/loop/for/await.md).

# for-await

* [JS](/web/js.md)⟩ [syntax](broken://pages/-MkkESuTtsNsTLnJJJUC) ⟩ [for loops](/web/js/grammar/statement/loop/for.md) ⟩ for await
* [JS](/web/js.md) ⟩ [async](/web/js/async.md) ⟩ for await

{% hint style="success" %}
([⭐️ ES2018](/web/js/feature/es2018.md))&#x20;

work with <mark style="color:orange;">**streams**</mark> of <mark style="color:yellow;">**asynchronous events**</mark> using simple loops.

```javascript
(async function() {
  for await (const value of iterable) { ... }
})();
```

{% endhint %}

{% tabs %}
{% tab title="⭐️ 重點" %}
{% hint style="danger" %} <mark style="color:purple;">**for await...of**</mark> <mark style="color:red;">**doesn't**</mark>**&#x20;**<mark style="color:yellow;">**work**</mark> with <mark style="color:yellow;">**async iterators**</mark> that are <mark style="color:red;">**not**</mark>**&#x20;**<mark style="color:yellow;">**async iterables**</mark>.
{% endhint %}
{% endtab %}

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

* [ ] [JavaScript: The Definitive Guide](/web/master/ref/javascript-the-definitive-guide.md) ⟩ Ch. 12, 13
  {% endtab %}

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

* [ ] [for await...of](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for-await...of)
  {% endtab %}

{% tab title="🚧" %}

* [ ] async iterator
* [ ] async iterable
  {% endtab %}
  {% endtabs %}
