# element index

[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) ⟩ [element](https://lochiwei.gitbook.io/web/js/val/builtin/arr/element) ⟩ index

{% hint style="success" %} <mark style="color:yellow;">**(**</mark>[str](https://lochiwei.gitbook.io/web/js/val/prim/str "mention")<mark style="color:yellow;">**)**</mark>&#x20;

<mark style="color:yellow;">**array elements**</mark> are <mark style="color:yellow;">**numbered**</mark>, <mark style="color:yellow;">**starting from**</mark>**&#x20;**<mark style="color:blue;">**0**</mark>, this number is called the element's <mark style="color:purple;">**index**</mark>, an <mark style="color:purple;">**index**</mark> <mark style="color:red;">**must**</mark>**&#x20;**<mark style="color:yellow;">**be**</mark> <mark style="color:blue;">**non-negtive**</mark>**&#x20;integers**:exclamation:
{% endhint %}

{% tabs %}
{% tab title="🧨 雷區" %}
{% hint style="warning" %}
[element-index-is-string](https://lochiwei.gitbook.io/web/js/val/builtin/arr/element/index/element-index-is-string "mention")
{% endhint %}
{% endtab %}

{% tab title="⭐️ 重點" %}
{% hint style="info" %}
JavaScript arrays are <mark style="color:yellow;">**zero-based**</mark> and use <mark style="color:yellow;">**32-bit**</mark> indexes: the index of the first element is <mark style="color:yellow;">**0**</mark>, and the <mark style="color:red;">**highest possible index**</mark> is <mark style="color:blue;">**4294967294**</mark> (<mark style="color:yellow;">**2³²−2**</mark>).
{% endhint %}

{% hint style="warning" %}
JavaScript arrays <mark style="color:yellow;">**have**</mark> <mark style="color:red;">**no notion**</mark> of an “<mark style="color:yellow;">**out of bounds**</mark>” error. When you try to query a <mark style="color:red;">**nonexistent**</mark>**&#x20;**<mark style="color:yellow;">**property**</mark> of any object, you don’t get an error; you simply get [**undefined**](https://lochiwei.gitbook.io/web/js/val/prim/undefined).
{% endhint %}
{% endtab %}

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

* :white\_check\_mark: <mark style="color:purple;">**element index**</mark> is accessed throught [bracket-notation](https://lochiwei.gitbook.io/web/js/val/obj/prop/access/bracket-notation "mention").
  {% endtab %}

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

* Guides ⟩ Arrays ⟩ [Accessing and modifying array items](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/First_steps/Arrays#accessing_and_modifying_array_items) ⭐️
  {% endtab %}
  {% endtabs %}
