An array of methods

Involves type and true/false conversion
methods The return value describe
Array.isArray() Boolean Check whether it is an array
toString() String Convert an array to a string
Array.from(arrayLike) Array willPseudo arrayintoTrue array
Array.of(value1, value2, value3) Array Create an array: willA set of valuesConvert to an array

Note that the length of the array is obtained using the length property, not the method. About the Length attribute


Involves the addition, deletion, change, and interception of array elements
methods describe impact
push() To an array ofThe backInserts one or more elements and returns the result as a new arrayThe length of the It changes the original array
pop() Delete from arrayThe last oneElement returns the result ofThe deleted element It changes the original array
unshift() In the arrayThe front ofInserts one or more elements and returns the result as a new arrayThe length of the It changes the original array
shift() Delete from arrayThe first oneElement returns the result ofThe deleted element It changes the original array
slice() From an array ofextractOne or more of the specified elements returns the resultNew array It doesn't change the original array
splice() From an array ofdeleteOne or more of the specified elements returns the resultA new array of deleted elements It changes the original array
fill() Populating an array: Populates an array with a fixed valueNew array It doesn't change the original array
concat() Merge arrays: Joins two or more arrays, returning the resultNew array It doesn't change the original array
join() Converts an array to a string, returning the resultConverted string It doesn't change the original array
split() Assembles a string into an array using the specified delimiter It doesn't change the original string

Note:

  • split()String method, not array method.
  • Slice, splice, splitMust not be confused and confused.

Involves sorting, inversion
methods describe note
reverse() Invert the array and return the resultThe inverted array It changes the original array
sort() For array elements, the default isUnicodeIn order from smallest to largest It changes the original array
Involved element index
methods describe note
indexOf(value) Retrieves an array from front to back to see if it contains a specified element
lastIndexOf(value) Retrieves an array from back to front to see if it contains the specified element
includes(item) Whether the array contains the specified contents
find(function()) To find outThe first oneThe element that satisfies the condition
findIndex(function()) To find outThe first oneOf the elements that satisfy the conditionindex
every() This method returns true only when traversal is stopped by making sure that every element in the array satisfies the specified condition return true All is true.
some() This method returns true when traversal is stopped as long as one element in the array satisfies the specified condition The truth is the truth.

Related to traverse the
methods describe note
The for loop Don’t say much, but pay attention to… In and for… The usage and application scenarios of of
forEach() Similar to the for loop, but compatible with IE8 and beyond ForEach () has no return value. That is, its return value is undefined
map() Each item in the original array is processed to form a new array It doesn’t change the original array
filter() Filter array: items that return true form a new array and return trueNew array It doesn’t change the original array
reduce Receives a function as an accumulator and returns the result of the cumulative processing of the callback function

conclusion

Today I just summarized some of the basic uses of all the array apis, and I’ll look at each module in more detail.