You can use many different ways to iterate an array.

for

for (let i = 0; i < a.length; i += 1) {
  //a[i]
}

Iterates a, can be stopped using return or break and an iteration can be skipped using continue

forEach

a.forEach(f)

Iterates f on a without a way to stop

Example:

a.forEach(v => {
  console.log(v)
})

for..of

for (let v of a) {
  console.log(v)
}

Every

a.every(f)

Iterates a until f() returns false

Some

a.some(f)

Iterates a until f() returns true


Go to the next lesson