In JavaScript, the for each loop is not used. Instead, we can use the for...of loop to iterate over the elements of an array.
index.tsx119 chars12 lines
The for...of loop will iterate over each element of the array and assign it to the element constant. We can then use the element variable to perform whatever operation we want on each element of the array.
Note, however, that the for...of loop only works for iterable objects like arrays, maps, and sets. It will not work for objects or strings.
gistlibby LogSnag