ES6 new array method

ES6

In general, ES6 refers to ES3 and later versions, including ES5, ES6, ES7 and other new versions. Among them, ES6 changes have the greatest impact and the most far-reaching impact.

Add five new array iteration methods

The filter() method creates a new array that contains all the elements of the test implemented by the provided function. 
       The map() method creates a new array, and the result is that each element in the array is the return value after calling the provided function once.
       forEach traverses the array. The forEach() method executes the given function once for each element of the array.
       The every() method tests whether all elements in an array can pass the test of a specified function. It returns a boolean value.
       The some() method tests whether at least one element in the array has passed the provided function test. It returns a Boolean value. 

Other methods

The fill() method fills all elements in an array from the start index to the end index with a fixed value. Does not include the termination index.
       The indexOf() method returns the first index at which a given element can be found in the array, or -1 if it does not exist.
       Array.isArray() is used to determine whether the passed value is an Array.
       The Array.from() method creates a new, shallow-copy array instance from an array-like or iterable object.

Guess you like

Origin blog.csdn.net/qq_41995398/article/details/115267935