> 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/variable/declare/const/cant-reassign.md).

# const can't reassign

[JS](/web/js.md) ⟩ [statement](/web/js/grammar/statement.md) ⟩ [declaration](/web/js/grammar/declare.md) ⟩ [const](/web/js/variable/declare/const.md) ⟩ can't reassign

{% hint style="danger" %}
a [const](/web/js/variable/declare/const.md) <mark style="color:red;">**can't**</mark> be <mark style="color:yellow;">**reassigned**</mark>. ( 👉 [const can't reassign](/web/js/variable/declare/const/cant-reassign.md):exclamation:)
{% endhint %}

{% tabs %}
{% tab title="💈範例" %}

* replit：[const can't reassign](https://replit.com/@pegasusroe/const-cant-reassign#index.js)
* 👉 [⛔️ TypeError](/web/js/err/type.md) ⟩ [assignment to constant variable❗️](/web/js/err/type/const-no-reassign.md)

```javascript
const name = "Frank";

name = "Suzy";            // can't reassign❗
//     ^^^^^^
// ⛔ TypeError: Assignment to constant variable.
// (it means a const doesn't have to the "ability" to do reassignment)
```

{% 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. 5 ⟩ [Constants?](https://github.com/getify/You-Dont-Know-JS/blob/2nd-ed/scope-closures/ch5.md#constants)
  {% endtab %}
  {% endtabs %}
