1.find

Find finds an array item and returns the matched array item based on the criteria.

array.find(function(value, index, arr),thisValue)
Copy the code

Simple use:

Var arr =,2,3,4,5,6,7 [1]; var ar = arr.find(function(elem){ return elem>5; }); console.log(ar); //6 console.log(arr); / /,2,3,4,5,6,7 [1]Copy the code

2.map

A map is a traversal number group that generates a new array item based on the original array item according to the conditions, without affecting the original array item.

array.map(function(value, index, arr),thisValue)
Copy the code

Simple use:

Var arr =,2,3,4,5,6,7 [1]; var ar = arr.map(function(elem){ return elem*4; }); console.log(ar); //[4, 8, 12, 16, 20, 24, 28] console.log(arr); / /,2,3,4,5,6,7 [1]Copy the code

3.filter

Filter is to filter out the traversal number group according to the conditions that meet the conditions, without affecting the original array.

array.filter(function(value, index, arr),thisValue)
Copy the code

Simple use:

Var arr =,2,3,4,5,6,7 [1]; var ar = arr.filter(function(elem){ return elem>5; }); console.log(ar); / / [6, 7]. The console log (arr); / /,2,3,4,5,6,7 [1]Copy the code