ForEach loop on array


Another way to iterate over the elements of an array is to use the forEach method of the array. It gets a function as an argument and it will call that function with each one of the values of the array.


examples/js/foreach_loop_on_array.js
"use strict";

var names = ["Foo", "Bar", "Qux"];
names.forEach(function(v) {
    console.log(v);
})
// Foo
// Bar
// Qux