[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
example 1 of 2
[>_]Terminal
Output appears here when you press Run.
$ ▌