JavaScript knows two types of “foreach” loops:

  • for (idx in values) iterates over the indices of the array
  • for (val of values) iterates over the values of the array

Example:

 References

  • [1] MDN on for .. of