go through each element in array javascript code example
Example 1: javascript best way to loop through array
var len = arr.length;
while (len--) {
// blah blah
}
Example 2: javascript best way to iterate over array
[1,2,3,4,"df"].forEach((value, index) => console.log(index,value));
output
0 1
1 2
2 3
3 4
4 'df'