Some methods of array iteration

  1. for loop-the most common method
  2. arr.forEach (function (value, index, array) ())-traverse the array ----- map () is similar
  3. arr.filter (function (value, index, array) {return value> 20;})-filter array--returns a new array
  4. arr.some (function (val, index, arr) {return value> 20;})-Find whether there is no element that meets the condition, return Boolean value --- find the first element that meets the condition, then stop the loop- ---- every () is similar

Guess you like

Origin www.cnblogs.com/joeynkay/p/12735335.html