Skip to content

JS Access Array Elements

Syntax

Array elements in JavaScript are accessed using their index, with the first element having an index of 0.

let element = arrayName[index];

Example

let colors = ["Red", "Green", "Blue"];
console.log(colors[0]); // Outputs: Red
console.log(colors[2]); // Outputs: Blue