Five kinds of ways js iterate through an array of every filter forEach map some

ECMAScript 5 array defines five iterative method.

Each method receives two parameters, the number of values and the group index entries

every(): Given function, if the function returns true for every Returns true to run on each item in the array.
filter(): To run on each item in the array for a given function that returns the function returns an array of items to true.
forEach(): To run on each item in the array given function. This method has no return value.
map(): To run on each item in the array for a given function that returns the results of each array of function call.
some(): Given function, the function returns true if any one of the Returns true in the array each run.
The above method does not contain the value of the array changes.

Guess you like

Origin www.cnblogs.com/HeighWord/p/11440400.html