arr []
Try it yourself →Collection of ordered values.
Syntax
const name = [e1, e2, ...]
Description
An array is created with square brackets. Elements are accessed with a 0-based index.
Returns
Array.
Example
const colors = ["red", "purple"]; console.log(colors[0]); console.log(colors.length);
Expected output
red 2
When to use?
Keeping multiple values (items, scores) in a single variable.
Common mistakes
- ⚠️ Indexing starts at 0: the first element is arr[0].