> 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/val/func/boundary.md).

# function boundary

🚧 施工中

[JS](/web/js.md) ⟩ [value](/web/js/val.md) ⟩ [function](/web/js/val/func.md) ⟩ <mark style="color:purple;">**function boundary**</mark>

{% hint style="success" %}
(related to [function scope](/web/js/scope/function.md)) 🚧&#x20;
{% endhint %}

{% tabs %}
{% tab title="⭐️ 重點" %}
{% hint style="warning" %}
[break](/web/js/grammar/statement/flow/jump/break.md) / [continue](/web/js/grammar/statement/flow/jump/continue.md)&#x20;

* <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:purple;">**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="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) / [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> [function](/web/js/val/func.md) / [IIFE](/web/js/val/func/expr/iife.md) (which has <mark style="color:yellow;">**its own**</mark>**&#x20;**<mark style="color:purple;">**function boundary**</mark>):exclamation:
* <mark style="color:green;">**use**</mark> [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="📗 參考" %}

* [ ] [YDKJS: Scope & Closures (v.2)](/web/master/ref/book/you-dont-know-js-series-v.2/ydkjs-scope-and-closures-v.2.md) ⟩ Ch. 6 ⟩ [function boundaries](https://github.com/getify/You-Dont-Know-JS/blob/2nd-ed/scope-closures/ch6.md#function-boundaries)
  {% endtab %}
  {% endtabs %}
