one
1. for(let I = 0; I < arr.length; I++)
while
2. Arr.foreach () –> replace the normal for loop
-
Three parameters: val the current traversal data, index the current traversal data sequence number, arr the current traversal array
Author: have a name links: www.jianshu.com/p/3b7ccd380… The copyright of the book belongs to the author. Commercial reprint please contact the author for authorization, non-commercial reprint please indicate the source.
3. Arr.map ()–> Do data interaction “map”
(1) Returns a new array. The map() method does not change the original array.
(2)When using map, always return
(3) If there is no return, equivalent to forEach()
4. Arr. Filter () – > filtering
(1) The return of the filter method has only two cases: true/false; If true, the data is retained; if false, the data is deleted. Returns a new array, does not change the original array.
(2) Filter some unqualified “elements” and leave them if the callback returns true
5. Arr.some ()–> Return true if one of the elements in the array meets the criteria
- FindInArray function encapsulation
6. Arr. Every ()–> all elements in the array must meet the condition to return true
Eg: Check whether the array is odd
7. Each of the above five loop methods can accept two parameters
arr.forEach/map… (Loop callback function, who this points to)
2. Loop method with more complex internal parameters
1. Arr.reduce ()–> From left to right
(1) Find the sum of arrays
Theta 2 to the power
2. Arr.reduceright ()–> From right to left
3. The for… of…
- Arr.keys () array subscript
Arr.entries An entry in the () array