JavaScript - Summary of Common Methods for Arrays

  1. The pop() method removes the last element in the array
  2. The push() method adds one or more elements to the end of the array.
  3. The shift() method deletes the first element in the array.
  4. The unshift() method adds one or more elements to the beginning of the array.
  5. contact() concatenates two arrays
  6. The join() method splices the array into a string and returns the string
  7. The includes() method, whether the array contains a specified element, returns true if it does, otherwise returns false
  8. indexOf() method, returns the index number of the first occurrence of the specified element in the array, if not, returns -1 (commonly used to determine whether the array contains an element)
  9. The reverse() method reverses the order of the array.
  10. .sort() sorts according to the original algorithm, converts the array into a string, and then sorts in UTF-16
  11. splice() method. Arrays can be deleted, replaced, added

Guess you like

Origin blog.csdn.net/qq_50487248/article/details/132070708