Chapter 412m

JavaScript Arrays

Ordered collections of values.

This content is not yet available in si. Showing English version.

View in English →

Arrays

Arrays store ordered lists of values.

js
const fruits = ["apple", "banana", "cherry"];
console.log(fruits[0]);     // "apple"
console.log(fruits.length); // 3
fruits.push("date");        // add at end
fruits.pop();               // remove from end

Example

javascript
// Arrays in JavaScript
const colors = ["red", "green", "blue"];
console.log("First:", colors[0]);
console.log("Length:", colors.length);
colors.push("yellow");
console.log("After push:", colors);