# strict vs. sloppy

[JS](https://lochiwei.gitbook.io/web/js) ⟩ [concepts](https://lochiwei.gitbook.io/web/browser/concepts) ⟩ [environment](https://lochiwei.gitbook.io/web/js/concept/env) ⟩ [JS engine](https://lochiwei.gitbook.io/web/js/concept/env/js-engine) ⟩ [mode](https://lochiwei.gitbook.io/web/js/concept/env/js-engine/mode) ⟩ strict vs. sloppy

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

* [strict-mode](https://lochiwei.gitbook.io/web/js/concept/env/js-engine/mode/strict-mode "mention") / [sloppy-mode](https://lochiwei.gitbook.io/web/js/concept/env/js-engine/mode/sloppy-mode "mention")
  {% endtab %}

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

* [ ] [javascript-the-definitive-guide](https://lochiwei.gitbook.io/web/master/ref/javascript-the-definitive-guide "mention") ⟩ 5.6.3 "use strict"
  {% endtab %}

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

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

<table><thead><tr><th width="306">⭐️ feature</th><th width="197.33333333333331">🛡️ strict mode</th><th>❗️ sloppy mode</th></tr></thead><tbody><tr><td><a data-mention href="../../../../grammar/statement/other/with">with</a> statement</td><td><span data-gb-custom-inline data-tag="emoji" data-code="274c">❌</span> forbidden</td><td><span data-gb-custom-inline data-tag="emoji" data-code="2705">✅</span> OK</td></tr><tr><td><a data-mention href="../../../../variable">variable</a> must be declared</td><td><span data-gb-custom-inline data-tag="emoji" data-code="2705">✅</span> yes</td><td><span data-gb-custom-inline data-tag="emoji" data-code="274c">❌</span> no</td></tr><tr><td><a data-mention href="../../../execution-context/this">this</a> context of function</td><td><a data-mention href="../../../../val/prim/undefined">undefined</a></td><td><a data-mention href="../../../../scope/global/object">object</a></td></tr><tr><td><a data-mention href="../../../../grammar/op/assign">assign</a> to non-writable property / create property on non-extensible object</td><td><span data-gb-custom-inline data-tag="emoji" data-code="26d4">⛔</span> TypeError</td><td><span data-gb-custom-inline data-tag="emoji" data-code="2757">❗</span> fails silently</td></tr><tr><td></td><td></td><td>🚧 ... to be continued</td></tr></tbody></table>
