forEach()
accepts two arguments.
forEach()
runs the given function on every item in the array.
forEach() has no return value.
The function passed in receives three arguments.
It is the same as iterating over an array with a for loop.
var numbers = [1,2,3,4,5,4,3,2,1];
numbers.forEach(function(item, index, array){
console.log(item);
});
The code above generates the following result.
forEach()
does not change the values contained in the array.