Array common update method

 Modify the original array directly

push()

 Adds one or more elements to the end of the array and returns the new length

pop() Remove and return the last element of the array
shift() removes and returns the first element in the array
unshift() Adds one or more elements to the beginning of the array and returns the new length
splice()

Add/remove items from an array and return the removed item

arrayObject.splice(index,howmany,item1,…,itemX)

index is required. An integer specifying where to add/remove items, use a negative number to specify a position from the end of the array.
howmany Required. The number of items to delete. If set to 0, items will not be removed.
item,...,itemX optional. New items added to the array.

sort() Used to sort the elements of an array, returning an array in ascending order
reverse() Used to reverse the order of elements in an array and return an array in reverse order

Will not replace the original array, but will generate a new array 

filter() Creates a new array whose elements are checked by checking all elements in the specified array that meet the criteria
concat() Used to concatenate two or more arrays. Does not change the existing array, but just returns a copy of the concatenated array
slice()

Used to extract elements from the array, encapsulate the intercepted elements into a new array and return [start, end)

Parameters:
      1. The index of the start position of the interception, including the start index
      2. The index of the end position of the interception, excluding the end index
             - The second parameter can be omitted, and all elements from the start index to the later will be intercepted
      - The index can pass a negative value, if a negative value is passed, it will be calculated from the back to the front

Guess you like

Origin blog.csdn.net/m0_50789696/article/details/129271075