Many values, one name
Imagine keeping your shopping list in separate variables: item1, item2, item3… It gets silly fast. An array keeps a whole list under one name.
Making and reading arrays
const fruits = ["mango", "banana", "litchi"]; console.log(fruits); console.log(fruits[0]); console.log(fruits[2]); console.log(fruits.length);
A numbered shelf: Picture a shelf with numbered spots: 0, 1, 2… Each spot holds one thing. The array is the whole shelf; the index is the spot number.
const scores = [72, 88, 95]; const last = scores[scores.length - 1]; console.log(last); console.log(scores[5]);