--- array method does not change the original array method

1.concat () to the engagement elements of the array.

concat () method is used to connect two or more arrays.

This method does not change the existing array, but only returns a copy of the array is connected.

2.every () method uses the specified function of all elements in the array detector:

  • If the array has a detected element is not satisfied, then the whole expression evaluates  to false  , and the remaining elements will not be detected.
  • If all elements satisfy the conditions are true

3.filter () returns the array elements to meet the assertion function.

4.forEach () to call the specified function for each element of the array.

5indexOf () to find the specified elements in the array. If found, returns the index of the element not found returns -1

6.join () of all elements of the array into a string.

var fruits = ["Banana", "Orange", "Apple", "Mango"];
var energy = fruits.join();
console.log(fruits)
console.log(energy)

[ 'Banana', 'Orange', 'Apple', 'Mango' ]
Banana,Orange,Apple,Mango

7.lastIndexOf () reverse lookup in the array.

8.map () from the elements of the array, a new array is calculated.

9.some () test if there is at least one element of the array function allows assertion is true.

10.slice () Returns part of an array.

var fruits = ["Banana", "Orange", "Lemon", "Apple", "Mango"];
var citrus = fruits.slice(1,3);
The results output Orange, Lemon

11.reduce () from the element of the array, a value is calculated.

A parameter receiving function receives two parameters function value is a first array, the second is the initial value is 0, then no transfer cycle is called a return value of the function is a second front parameter later

12.reduceRight () is calculated from right to left array

Guess you like

Origin www.cnblogs.com/buxiugangzi/p/12079003.html