Javascript example: iterate over array
Example iterating over array using Javascript
This snippet shows several ways to visit every item in a JavaScript array of fruit names. It compares an index-based for loop, for...of, forEach, map, and for...in, highlighting that map is normally for transformations and for...in is not recommended for arrays.