Iterator Foreachevery One, iterator method
Iterator methods, which apply a function to each element in an array, and can return a value, a set of values, or a new array
Iterator method that does not generate a new array
1.forEach ()
ForEach ()
Output
foreach Output results
2.every ()
The method uses the function for each element in an array by accepting a function that returns a Boolean value, and if, for all elements, the return value is True, the method returns true, otherwise false
Every ()
When nums = [2,4,6,8,10] is output all numbers is even, nums = [1,2,3,4,5] When output not all ...
The Some () method also accepts a function that returns a Boolean value, but the method returns true whenever an element returns TRUE.
3.reduce ()
The method takes a function that returns a value. The method starts with an accumulated value, continues to use the function for the accumulated value and the elements after it, until the last element of the array, and then returns the accumulated value.
Reduce ()
JS Array method (ForEach (), every (), reduce ())