JavaScript/Referring to array elements
[i]Learn· Indexed collections

Referring to array elements

Because elements are also properties, you can access them using property accessors. Suppose you define the following array:

const myArray = ["Wind", "Rain", "Fire"];

You can refer to the first element of the array as myArray[0], the second element of the array as myArray[1], etc. The index of the elements begins with zero.

Note: You can also use property accessors to access other properties of the array, like with an object.

const arr = ["one", "two", "three"];
arr[2]; // three
arr["length"]; // 3
Source: Indexed collections by Mozilla Contributors, licensed under CC-BY-SA-2.5. Retrieved 2026-11-18. Changes: Extracted the section "Referring to array elements"; removed the code-block language labels; made links absolute; examples are the page's own code blocks, unchanged.