Skip to content

Arrays

Read · 1 of 4

Positions start at 0

const marks = [70, 85, 90]; makes an array. marks[0] is the first value, marks[2] the last, and marks.length is 3.

marks.push(x) adds x at the end. Reading a position that doesn't exist gives undefined instead of crashing, which hides bugs: check your positions.

for (const x of marks) visits every value in order.