Javascript - Accessing Elements
Code Life
By Pierre Marsaa
Picking One Element
An array keeps its elements in order, and each one has a position called an index. To read an element, write the array name followed by the index in square brackets:
↗️
Loading editor...
↶
↷
Surprise: the first index is 0, not 1! Aquachu is at index 0, Pyrochu at index 1, Florachu at index 2. This is the most common source of confusion with arrays, so remember: counting starts at 0.
Index
Element
0
Aquachu
1
Pyrochu
2
Florachu
Verify