array
map
can traverse an array and return a new array
TEXT
1
2
3
4
5
<array>.map(function(element,index){
element //array element
index //array index
return element + 10 //Can be modified
})
forEach
can traverse an array,but cannit return
TEXT
1
2
3
4
<array>.forEach(function(element,index){
element //array element
index //array index
})
- index optional
filter
can traverse an array and return a new array
TEXT
1
2
3
4
5
<array>.filter(function(element,index){
element //array element
index //array index
return element > 10 //Can be compared
})
reduce
Return the cumulative processing result, used for summation
TEXT
1
2
3
<array>.reduce(function(prev,current){
return prev + current
},<initial value>)
join
convert an array to a string
TEXT
1
<array>.join(["split symbol"])
if the split symbol is empty,it is comma separated