# stop using var❗️

[JS](/web/js.md) ⟩ [variable](/web/js/variable.md) ⟩ [var](/web/js/variable/declare/var.md) ⟩ stop using var:exclamation:

{% hint style="warning" %}

* [var is a statement❗️](/web/js/variable/declare/var/var-is-a-statement.md)(<mark style="color:orange;">**side effects**</mark>)
* [global var / function is global object property❗️](/web/js/variable/declare/var/is-global-obj-prop.md)(<mark style="color:orange;">**side effect**</mark>)
* [accessing var before declaration gets undefined❗️](/web/js/variable/declare/var/accessing-var-before-declaration-gets-undefined.md)(<mark style="color:red;">**unexpected result**</mark>)
* [var has no block scope❗️](/web/js/variable/declare/var/in-block-cant-shadow.md) (<mark style="color:red;">**unexpected result**</mark>)
* [var in block can't shadow outer let❗️](/web/js/variable/declare/var/var-in-block-cant-shadow-outer-let.md)(<mark style="color:red;">**unexpected result**</mark>)
* [var can shadow parameter even in strict mode❗️](/web/js/variable/declare/var/param-by-var.md)(<mark style="color:yellow;">**bad practice**</mark>)
* [var redeclaration applied even in strict mode❗️](/web/js/variable/declare/var/redeclare.md)(<mark style="color:yellow;">**bad practice**</mark>)
  {% endhint %}

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

* [statement expected❗️](/web/js/grammar/statement/statement-expected.md):exclamation:
* :white\_check\_mark: [always use strict mode](/web/js/concept/env/js-engine/mode/strict-mode/always.md)
  {% endtab %}

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

* [ ] [Statements and declarations](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements) ⟩ [declaring variables](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements#declaring_variables) ⟩ [var](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/var)
* [ ] [Difference between statements and declarations](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements#difference_between_statements_and_declarations) ⭐️⭐️⭐️ ❗️❗️❗️
  {% 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/variable/declare/var/stop-using-var.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.
