An an array is a list of ordered, stored data. They can hold items that are of any data type.
Arrays are often created by using square brackets, with individual elements separated by commas.
array = [element1, element2, element3, element4]
We access an array element by referring to the index number. An index is the element’s position in a sequence.
A lot of times, array indices start with 0:
grocery = ["milk", "cookies", "berries", "carrots"]// index: 0 1 2 3
- The first element is at index 0.
- The second element is at index 1.
- The third element is at index 2.
- …and so on.
Arrays in Different Languages
- Anonymous contributor
Learn More on Codecademy
- Anonymous contributorAnonymous contributor