Arrays: Ordered Lists
Learn how to store multiple values in a single variable using arrays — JavaScript's ordered, numbered lists.
One variable, many values
So far, each variable has held a single value — one name, one score, one boolean. But what if you need to store a list of things? A playlist of songs, a class roster of student names, a shopping cart of items? You could create separate variables (`song1`, `song2`, `song3`...), but that quickly becomes unmanageable.
Arrays solve this problem. An array is an ordered list of values stored in a single variable. You create one with square brackets `[]`, placing values inside separated by commas. Arrays can hold any type of data — strings, numbers, booleans, even other arrays.
JavaScript arrays are actually a special type of object. Unlike arrays in some other languages, JavaScript arrays can hold mixed types (strings and numbers together), grow and shrink dynamically, and have no fixed size. They are one of the most commonly used data structures in all of programming.