# array length

[JS](https://lochiwei.gitbook.io/web/js) ⟩ [object](https://lochiwei.gitbook.io/web/js/val/obj) ⟩ [built-in](https://lochiwei.gitbook.io/web/js/val/builtin) ⟩ [Array](https://lochiwei.gitbook.io/web/js/val/builtin/arr) ⟩ length

{% hint style="success" %}

* array <mark style="color:purple;">**length**</mark> is <mark style="color:yellow;">**automatically maintained**</mark> by the array.
* if you assign <mark style="color:blue;">`a[i] = value`</mark>, where <mark style="color:yellow;">i ≥ a.length</mark>, a.length is set to <mark style="color:blue;">`i+1`</mark>.
* if you set <mark style="color:blue;">`a.length = n`</mark>, where <mark style="color:yellow;">n < a.length</mark>, then any elements whose <mark style="color:yellow;">index ≥ n</mark> are <mark style="color:yellow;">**deleted**</mark>.
  {% endhint %}

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

* [ ] [javascript-the-definitive-guide](https://lochiwei.gitbook.io/web/master/ref/javascript-the-definitive-guide "mention") > 7.4 Array Length
  {% endtab %}
  {% endtabs %}
