var array = [23,48,66,2];
ForEach: Loops, iterates through an array, no return value. Similar to For Loop Array.foreach (function (value, index, array) { console.log (value); return value * value;});
Map : The map means that the map returns a new array with a return value; Filterarr: Returns a new object var Maparr = Array.map (function (value, index, array) {return value * value;});
Filter : The meaning of filtering, filtering, return value; Filterarr: Returns the newly filtered array var Filterarr = Array.filter (function (value, index, array) { if (value >) { return true; } return false;});
Everyarr: Every one, every meaning; return value; every: Returns Boolean true or false; var Everyarr = array.every (function (value, index, array) { if (value > 1) { return true; }});
IndexOf: The first one is the retrieved value, the second is the location to retrieve it from 0 onwards Console.log (Array.indexof (23,0));
LastIndexOf: The first is the retrieved value, the second is the location to be retrieved from Arr.length-1 Console.log (Array.lastindexof (2,10));
//Initial setupprevious = InitialValue = 1, current = 2
//First Iteration previous = (1 + 2) = 3, current = 3
//Second Iteration Previous = (3 + 3) = 6, current = 4
//Third Iteration Previous = (6 + 4) = Ten, current = undefined (exit)var reduce = [1,2,3,4].reduce (function (prev, Curr, index, array) { Console.log (prev + " + Curr); return prev + Curr;});
//Initial setup index = 3, previous = InitialValue = 4, current = 3
//First Iteration index = 2, previous = (4-3) = 1, current = 2
//Second Iteration index = 1, previous = (1-2) =-1, current = 1
//Third Iteration index = 0, previous = ( -1 + 1) = 0, current = undefined (exit)var reduceright = [1,2,3,4].reduceright (function (prev, Curr, index, array) { if (index = = 0) { return prev + cur R; } return prev-curr;});
Console.log (Reduceright);
ES5 in array new API interface ForEach map filter Some every indexOf lastIndexOf reduce reduceright