Utilizor
Contact Us

Accessing Elements

Reading and writing array elements.

Accessing Elements

You access an array element by referring to the index number.

Array indexes start with 0. [0] is the first element. [1] is the second element.

let car = cars[0];

You can also change an element by assigning a new value to the index.

cars[0] = "Opel";

Example

const cars = ["Saab", "Volvo", "BMW"];
let x = cars[0];