All Array method in JavaScript

All Array method in JavaScript

  1. push(element1, element2, ...):
    Adds one or more elements to the end of an array.

  2. pop():
    Removes and returns the last element of an array.

  3. unshift(element1, element2, ...):
    Adds one or more elements to the beginning of an array.

  4. shift():
    Removes and returns the first element of an array.

  5. concat(array1, array2, ...):
    Combines two or more arrays and returns a new array.

  6. join(separator):
    Joins all elements of an array into a string, separated by the specified separator.

  7. slice(start, end):
    Creates a new array containing a portion of the original array from start to end (end index not included).

  8. splice(start, deleteCount, item1, item2, ...):
    Changes the contents of an array by removing, replacing, or adding elements.

  9. reverse():
    Reverses the order of elements in an array.

  10. sort(compareFunction):
    Sorts the elements of an array in place, optionally using a custom comparison function.

  11. filter(callback):
    Creates a new array with all elements that pass the test implemented by the provided callback function.

  12. map(callback):
    Creates a new array by applying a callback function to each element of the original array.

  13. forEach(callback):
    Executes a provided callback function once for each array element.

  14. find(callback):
    Returns the first element in an array that satisfies the provided testing function.

  15. findIndex(callback):
    Returns the index of the first element in an array that satisfies the provided testing function.

  16. every(callback):
    Check if all elements in an array pass a provided test implemented by the callback function.

  17. some(callback):
    Checks if at least one element in an array passes a provided test implemented by the callback function.

  18. reduce(callback, initialValue):
    Applies a callback function against an accumulator and each element in the array (from left to right) to reduce it to a single value.

  19. reduceRight(callback, initialValue):
    Applies a callback function against an accumulator and each element in the array (from right to left) to reduce it to a single value.

  20. includes(element):
    Checks if an array includes a certain element and returns true or false.

  21. indexOf(element, fromIndex):
    Returns the first index at which a given element can be found in the array, or -1 if it is not present.

  22. lastIndexOf(element, fromIndex):
    Returns the last index at which a given element can be found in the array, or -1 if it is not present.