Array (JavaScript)
An array is an ordered list of values stored in a single variable. You access items by their numeric index, starting at 0.
JavaScript
Arrays can hold any mix of values and grow or shrink as needed. Common methods include push() to add, pop() to remove, and length to count items.
Methods like map, filter, and reduce make arrays powerful for transforming data.
Syntax
const arr = [item1, item2, item3];Examples
JavaScript
const fruits = ["apple", "banana"];
fruits.push("cherry");
console.log(fruits[2]);
console.log(fruits.length);Output:
cherry
3