> 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/flow/jump/continue.md).

# continue

skips to the next iteration of the current/labeled loop.

[JS](/web/js.md) ⟩ [statement](/web/js/grammar/statement.md) ⟩ [control flow](/web/js/grammar/statement/flow.md) ⟩ continue

{% hint style="success" %}
([statement](/web/js/grammar/statement.md)) <mark style="color:yellow;">**skip**</mark> to the <mark style="color:yellow;">**next**</mark> [iteration](/web/js/iteration.md) of the <mark style="color:orange;">**current**</mark>**&#x20;**<mark style="color:yellow;">**/**</mark> [**labeled**](/web/js/grammar/statement/other/label.md) [loop](/web/js/grammar/statement/loop.md).

```javascript
continue;          // skips to next iteration of current loop
continue label;    // skips to next iteration of labeled loop
```

{% endhint %}

{% tabs %}
{% tab title="🧨 雷區" %}
{% hint style="danger" %} <mark style="color:purple;">**continue**</mark> <mark style="color:yellow;">**statement**</mark> can be used <mark style="color:red;">**only**</mark>**&#x20;**<mark style="color:yellow;">**within the body of**</mark> a [loop](/web/js/grammar/statement/loop.md), using it <mark style="color:yellow;">**anywhere**</mark>**&#x20;**<mark style="color:red;">**else**</mark> causes a [<mark style="color:red;">**SyntaxError**</mark>](/web/js/err/syntax.md).
{% endhint %}
{% endtab %}

{% tab title="⭐️ 重點" %}
{% hint style="success" %} <mark style="color:yellow;">**nested**</mark> [loop](/web/js/grammar/statement/loop.md)

* [**labeled**](/web/js/grammar/statement/other/label.md) <mark style="color:yellow;">**statement**</mark> is <mark style="color:red;">**needed**</mark> when you want to <mark style="color:purple;">**skip**</mark> <mark style="color:yellow;">**to**</mark> the <mark style="color:yellow;">**next iteration**</mark> of <mark style="color:yellow;">**an outer loop**</mark> that is <mark style="color:red;">**not**</mark>**&#x20;**<mark style="color:yellow;">**the**</mark>**&#x20;**<mark style="color:red;">**nearest**</mark>**&#x20;**<mark style="color:yellow;">**enclosing**</mark> [loop](/web/js/grammar/statement/loop.md).
  {% endhint %}

{% hint style="warning" %}
[break](/web/js/grammar/statement/flow/jump/break.md)/<mark style="color:purple;">**continue**</mark> <mark style="color:red;">**won't**</mark> operate <mark style="color:yellow;">**across**</mark> an [IIFE](/web/js/val/func/expr/iife.md) <mark style="color:yellow;">**function boundary**</mark> to control an <mark style="color:yellow;">**outer**</mark> [loop](/web/js/grammar/statement/loop.md)/[block](/web/js/grammar/statement/other/block.md).

📗 [You Don't Know JS Yet: Scopes & Closrues](https://github.com/getify/You-Dont-Know-JS/blob/2nd-ed/scope-closures/ch6.md#invoking-function-expressions-immediately)
{% endhint %}

{% hint style="success" %}
[label](/web/js/grammar/statement/other/label.md) is <mark style="color:red;">**only**</mark>**&#x20;**<mark style="color:yellow;">**used by**</mark> [break](/web/js/grammar/statement/flow/jump/break.md) <mark style="color:yellow;">**/**</mark> <mark style="color:purple;">**continue**</mark>.
{% endhint %}

{% hint style="danger" %}
if the <mark style="color:yellow;">**code**</mark> you need to <mark style="color:yellow;">**wrap**</mark> a [scope](/web/js/scope.md) <mark style="color:yellow;">**around**</mark> has [return](/web/js/grammar/statement/flow/jump/return.md), [this](/web/js/concept/execution-context/this.md), [break](/web/js/grammar/statement/flow/jump/break.md), or [continue](/web/js/grammar/statement/flow/jump/continue.md) in it, <mark style="color:red;">**don't**</mark>**&#x20;**<mark style="color:yellow;">**use**</mark> a [function](/web/js/val/func.md)/[IIFE](/web/js/val/func/expr/iife.md)(which has <mark style="color:yellow;">**its own**</mark> [function boundary](/web/js/val/func/boundary.md)), use a [block](/web/js/grammar/statement/other/block.md) instead❗️

📗 [You Don't Know JS Yet: Scopes & Closrues](https://github.com/getify/You-Dont-Know-JS/blob/2nd-ed/scope-closures/ch6.md#function-boundaries)
{% endhint %}
{% endtab %}

{% tab title="🔴 主題" %}

* [continue vs. break](/web/js/grammar/statement/flow/jump/continue-vs.-break.md)
  {% endtab %}

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

* [iteration](/web/js/iteration.md)
* [label](/web/js/grammar/statement/other/label.md) statement
  {% endtab %}

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

* [ ] [Statements and declarations](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements) ⟩ [control flow](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements#control_flow) ⟩ [continue](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/continue) ⭐️
* [ ] [Loops and iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Loops_and_iteration) ⟩ [continue statement](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Loops_and_iteration#continue_statement)
  {% endtab %}
  {% endtabs %}
