Data Structures
What Is an Array?
An array is a collection of values stored in order, where each value is reached by its position number, called an index.
Definition
An array holds several values under one name, in a fixed order. Each value sits at a numbered position. In most languages the first position is index 0, so an array of five items uses indexes 0 to 4.
Reading any item by its index is fast, because the computer can jump straight to that position.
How it works
In C and Java an array has a fixed size and holds one type of value, stored side by side in memory. JavaScript arrays and Python lists grow and shrink as needed and can mix types.
Reading or replacing an item by index takes constant time, O(1). Inserting or removing near the start is slower, O(n), because every item after it has to shift.