Arrays
Learn about arrays with examples.
So far, we’ve met primitive data types, such as strings, numbers and Booleans. But what if we want to store a whole collection of values in a single variable? For example, we might have a list of prices that we want store in the same place. Composite data types can be used to collect primitive values in a structured way.
Programming languages use a variety of different data structures to store values, but one of the most common is an array.
What is an array?
An array is an ordered list of values. For example, consider the following shopping list:
- Apple
- Banana
- Cupcake
This could be represented as the following array:
['Apple', 'Banana', 'Cupcake']
Get hands-on with 1400+ tech skills courses.