> 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/element/index.md).

# element index

[JS](/web/js.md) ⟩ [object](/web/js/val/obj.md) ⟩ [built-in](/web/js/val/builtin.md) ⟩ [Array](/web/js/val/builtin/arr.md) ⟩ [element](/web/js/val/builtin/arr/element.md) ⟩ index

{% hint style="success" %} <mark style="color:yellow;">**(**</mark>[String](/web/js/val/prim/str.md)<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❗️](/web/js/val/builtin/arr/element/index/element-index-is-string.md)
{% 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**](/web/js/val/prim/undefined.md).
{% endhint %}
{% endtab %}

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

* :white\_check\_mark: <mark style="color:purple;">**element index**</mark> is accessed throught [bracket notation \[\]](/web/js/val/obj/prop/access/bracket-notation.md).
  {% 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 %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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/val/builtin/arr/element/index.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.
