1. The find() method, which finds the first eligible array member. It takes a callback function that all members of the array execute until the first member returns true, and then returns that member. If there is no qualified member, undefined is returned.

Example: [1, 2, 5, -1, 9]. Find ((n) => n < 0

Note: find() does not change the original value of the array.

2. The findIndex() method is used in much the same way as the find() method, returning the position of the first eligible array member, or -1 if all members fail.

Example: [1, 2, 5, 1, 9]. FindIndex ((n) = > n < 0) — – > 3

Note that findIndex() does not change the original value of the array.

3. The filter() method tests all elements with the specified function and creates a new array containing all elements that pass the test. Filter does not change the original array. Returns an array containing all elements that match the criteria. An empty array is returned if no element matches the criteria.

Var newArr = arr.fiulter(item=> item> 3)

// Array decrement

var arr = [1, 2, 2, 3, 4, 5, 5, 6, 7, 7, 8, 8, 0, 8, 6, 3, 4, 56, 2];

var arr2 = arr.filter((x, index,self)=>self.indexOf(x) === index)

console.log(arr2); // [1, 2, 3, 4, 5, 6, 7, 8, 0, 56]

4, forEach through all the elements of the number group, no return value, no effect on the original array, IE is not supported

Arr. ForEach (function (item, index, arr) {

  console.log(item);

});

5, some() checks if there is at least one element in the array, and returns true if there is one element, or false if there is none

arr2.some(function(value, index, array){

  return value % 2 == 0;
Copy the code

}) // true

6, every() checks whether every element in the array meets the condition, and returns true only when the condition is met. Return false if one of these is not satisfied

arr2. every (function(value, index, array){

     return value % 2 == 0;

   }) // false

7. The map() method returns a new array whose elements are the values of the original array

var data = [1, 2, 3, 4];

var arrayOfSquares = data.map(function (item) {

  return item + 1;

})

console.log(arrayOfSquares); / / 5-tetrafluorobenzoic [2]

8. For in traversal, which can simply be thought of as the more advanced for(){}, is an array unfriendly property used to traverse objects

for(var key in myArray) {

console.log(myArray[key]);

}

Note: 1. Index is a string number. 3. Using for in iterates through all enumerable properties of an array, including stereotypes. For example, the “for in” archetype method and name attributes are better for iterating through objects than for iterating through groups of numbers.

9, for… Of applies to traversal numbers/array objects/strings/maps/sets that have iterator objects. But you cannot iterate over the object because there are no iterator objects. Unlike forEach(), it responds correctly to break, continue, and return statements

for(var value of myArray) {

console.log(value);

}