Variables that hold single values are fine for simple scripts, but real apps need to manage collections of data. Enter the Array — JavaScript's fundamental ordered data structure.
1What is a JavaScript Array?
An Array is a special type of object used to store multiple values in a single variable. Unlike a standard object which uses named keys, an array uses numeric indices. This makes arrays perfect for lists where order matters: a list of users, a series of coordinates, or the messages in a chat history.
2Zero-Based Indexing
Every element in an array sits at a numbered position called an index. Critically, the first element is at index 0, not 1. This is called zero-based indexing, and it applies consistently across JavaScript and most programming languages.
3The .length Property
Every array has a built-in .length property that automatically reflects the current number of elements. Add an item with .push() and .length increases by 1. Remove one with .pop() and it decreases. There is no need to track the count manually.
4Reference Types and Memory
This is one of the most important concepts in JavaScript: Arrays are Reference Types. When you write const b = a, you are not duplicating the array — you are copying the *address* in memory where the array lives. Both a and b now point to the same data.
5Arrays Are Objects (typeof Quirk)
Running typeof [] in JavaScript returns 'object', not 'array'. This surprises many developers. The reason: arrays are specialised objects with numeric string keys ('0', '1', '2'…) and an auto-updating length property.
