An array is an ordered list that holds multiple values in a single place, with each value reachable by its position number. Rather than juggling dozens of separate variables, you keep related things together in one container and ask for the item at position 3 or position 50 directly.

Picture an egg carton. It’s one object, but it has numbered slots, and you can point at slot four without disturbing the rest. An array works the same way: the values sit in order, each in its own numbered slot, and the computer can jump straight to any one of them. This is why arrays pair so naturally with a sorting algorithm, which rearranges the items into a useful order, and why a chunk of JSON often contains arrays to represent lists of things.

One quirk catches newcomers out: arrays usually start counting at zero, so the first slot is position 0, not 1. When you need to find values by a name instead of a position, a hash table is the better fit. The reason arrays are everywhere is speed. Because the slots sit side by side in memory, the computer can grab item number 4,000 just as fast as item number 4, with no searching at all. The catch is the size. A classic array is set up to hold a fixed number of items, so squeezing in an extra one can mean copying the whole thing to a bigger space. Most modern languages hide that behind a friendlier list type, but underneath it is still an array doing the work. Whenever you load a page of search results or a row of products on a shop, you are almost certainly looking at an array.

At TopDevs we reach for arrays constantly when handling lists of records for a client, because they keep related data tidy and let the software work through it quickly.