> 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/val/builtin/arr/length.md).

# array length

[JS](/web/js.md) ⟩ [object](/web/js/val/obj.md) ⟩ [built-in](/web/js/val/builtin.md) ⟩ [Array](/web/js/val/builtin/arr.md) ⟩ 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](/web/master/ref/javascript-the-definitive-guide.md) > 7.4 Array Length
  {% endtab %}
  {% endtabs %}
