array 

Send to Kindle
home » snippets » javascript » array



Methods

forEach

Ref:  forEach()

Note:  There is no way to stop or break a forEach loop.  The solution is to use Array.every or Array.some (return false to break the loop.)

var colors = ['red', 'green', 'blue'];
console.log(".forEach on " + colors);
colors.forEach(function(value, index, arr) {
  console.log("a[%s] = %s", value, index);
});