What are the commonly used methods of arrays in ES6?

There are several commonly used methods for arrays in ES6.

  1. forEach(): perform a specified operation on each element in an array.
  2. map() creates a new array where the elements are the result of a specified operation applied to each element of the original array.
  3. filter(): creates a new array with elements that meet a specific condition from the original array.
  4. find(): return the first element in the original array that satisfies the specified condition.
  5. findIndex(): returns the index value of the first element in the original array that meets the specified condition.
  6. some(): Determines if at least one element in the original array satisfies a specified condition.
  7. every() determines whether all elements of the original array satisfy a specified condition.
  8. reduce(): Perform a specified merging operation on all elements in the original array and return the merged result.
  9. reduceRight() performs a specified merging operation on all elements of the original array from right to left and returns the resulting merged value.
  10. sort(): arrange the original array in order.
  11. reverse(): reverse the order of elements in the original array.
  12. includes(): Determines whether the original array contains a specified element.
  13. indexOf(): returns the index of the first occurrence of a specified element in the original array.
  14. lastIndexOf(): Returns the index of the last occurrence of a specified element in the original array.
  15. slice() returns a portion of the original array.
  16. splice(): perform insert, delete, and update operations on the original array.
  17. concat(): Combines multiple arrays into a single new array.
  18. join(): Concatenate all elements in the original array into a single string with a specified separator.
  19. fill(): Fill the original array with the specified value.
  20. Array.from() converts an array-like object or iterable object into an array.

The above are commonly used methods in ES6 for arrays, which can be used for various operations and processing on arrays.

bannerAds