# sloppy mode

[JS](/web/js.md) ⟩ [concepts](/web/browser/concepts.md) ⟩ [environment](/web/js/concept/env.md) ⟩ [JS engine](/web/js/concept/env/js-engine.md) ⟩ [mode](/web/js/concept/env/js-engine/mode.md) ⟩ sloppy

{% hint style="success" %}
:u6307: synonyms： "<mark style="color:purple;">**non-strict mode**</mark>", "<mark style="color:purple;">**sloppy mode**</mark>"

:point\_right: compare： [strict mode](/web/js/concept/env/js-engine/mode/strict-mode.md)
{% endhint %}

{% tabs %}
{% tab title="⭐️ 重點" %}
{% hint style="warning" %} <mark style="color:red;">**in**</mark> <mark style="color:purple;">**sloppy mode**</mark>：

* although [scope](/web/js/scope.md)s are <mark style="color:yellow;">**determined**</mark> at [compile-time](/web/js/compile/compile-time.md), you can <mark style="color:red;">**modify**</mark> the [scope](/web/js/scope.md) at [runtime](/web/js/compile/runtime.md):exclamation: ( 👉 [modify current scope at runtime❗️](/web/js/concept/env/js-engine/mode/sloppy-mode/modify-current-scope-at-runtime.md):exclamation:)
* [function in block (FiB)](/web/js/val/func/declare/function-in-block-fib.md) is [<mark style="color:yellow;">**hoisted**</mark>](/web/js/scope/hoist/function.md) / <mark style="color:yellow;">**initialized**</mark> to [undefined](/web/js/val/prim/undefined.md) (<mark style="color:orange;">**outside the**</mark> [block](/web/js/grammar/statement/other/block.md)):exclamation:
* [assignment (=)](/web/js/grammar/op/assign/assignment.md) to [undeclared identifier](/web/js/grammar/token/id/undeclared.md) will result in [accidental global variable in sloppy mode❗️](/web/js/concept/env/js-engine/mode/sloppy-mode/accidental-global-variable-in-sloppy-mode.md)
  {% endhint %}

{% hint style="warning" %}
JS is <mark style="color:green;">**lenient**</mark> with [var](/web/js/variable/declare/var.md), <mark style="color:red;">**strict**</mark> with [let](/web/js/variable/declare/let.md).

* [var redeclaration applied even in strict mode❗️](/web/js/variable/declare/var/redeclare.md), even in [strict mode](/web/js/concept/env/js-engine/mode/strict-mode.md):exclamation:
* [let redeclaration not allowed even in sloppy mode❗️](/web/js/variable/declare/let/no-redeclare.md), even in [sloppy mode](/web/js/concept/env/js-engine/mode/sloppy-mode.md):exclamation:
  {% endhint %}

{% hint style="warning" %}
with a [function in block (FiB)](/web/js/val/func/declare/function-in-block-fib.md)

* [sloppy mode](/web/js/concept/env/js-engine/mode/sloppy-mode.md): ✅ [<mark style="color:yellow;">**hoisted**</mark>](/web/js/scope/hoist/function.md) / <mark style="color:yellow;">**initialized**</mark> to [undefined](/web/js/val/prim/undefined.md) (in <mark style="color:orange;">**outer**</mark> [scope](/web/js/scope.md))
* [strict mode](/web/js/concept/env/js-engine/mode/strict-mode.md): ⛔ [<mark style="color:red;">**ReferenceError**</mark>](/web/js/err/ref/not-defined.md) (<mark style="color:yellow;">**invisible**</mark> in <mark style="color:orange;">**outer**</mark> [scope](/web/js/scope.md)):exclamation:
  {% endhint %}
  {% endtab %}

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

* [accidental global variable in sloppy mode❗️](/web/js/concept/env/js-engine/mode/sloppy-mode/accidental-global-variable-in-sloppy-mode.md):exclamation:
* [modify current scope at runtime❗️](/web/js/concept/env/js-engine/mode/sloppy-mode/modify-current-scope-at-runtime.md):exclamation:
  {% endtab %}

{% tab title="🖥️ 影片" %}
{% embed url="<https://youtu.be/G9QTBS2x8U4>" %}
{% endtab %}

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

* [ ] [Strict mode](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode)
* [ ] [Sloppy mode](https://developer.mozilla.org/en-US/docs/Glossary/Sloppy_mode)
  {% endtab %}
  {% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://lochiwei.gitbook.io/web/js/concept/env/js-engine/mode/sloppy-mode.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
