foreach loop The foreach loop is one of the JavaScript statements that allows you to iterate over a set of values in a array. The syntax of the foreach loop is as follows:
The syntax for the for each loop is as follows:
var arr = [1,2,3,4,5,6,7,8,9,10];
arr.forEach(function(item, index, array) {
console.log(item, index);
});
Leave a Reply