1. Reduce function

Reduce summarizes the contents of an array

Var a =,20,30,40 [10]; Var b= a.pie ((total,item)=>{return total+item}, 0) console.log(b); //b=100Copy the code

2. The filter function

Filter Filters arrays

Var a = [1, 2, 3, 4]. var b=a.filter((item)=>{ return item>2 }) console.log(b); / / b = [3, 4]Copy the code

3. The map function

The map function changes the elements of the array as a whole

Var a = [1, 2, 3, 4]. var b=a.map((item)=>{ return item*2 }) console.log(b); / / b =,4,6,8 [2]Copy the code

4. Every and some functions

(2) Some evaluates each element in an array with one or more of the criteria set. (3) Some evaluates each element with one or more of the criteria set. (4) Some evaluates each element with one of the criteria set

Var a = [1, 2, 3, 4]. var b=a.every((item)=>{ return item>1 }) console.log(b); //falseCopy the code
Var a = [1, 2, 3, 4]. var b=a.some((item)=>{ return item<2 }) console.log(b); //trueCopy the code