JavaScript Array Methods Cheatsheet
1. Mutator methods
push(): Adds one or more elements to the end of an array and returns the new length of the array.
pop(): Removes the last element from an array and returns that element.
shift(): Removes the first element from an array and returns that element.
unshift(): Adds one or more elements to the beginning of an array and returns the new length of the array.
splice(): Changes the contents of an array by removing or replacing existing elements and/or adding new elements in place.
reverse(): Reverses the order of the elements of an array in place.
sort(): Sorts the elements of an array in place and returns the array.
2. Accessor methods
concat(): Returns a new array that is this array joined with other array(s) and/or value(s).
join(): Joins all elements of an array into a string.
slice(): Extracts a section of the calling array and returns a new array.
indexOf(): Returns the first (least) index of an element within the array equal to the specified value, or -1 if none is found.
lastIndexOf(): Returns the last (greatest) index of an element within the array equal to the specified value, or -1 if none is found.
3. Iteration methods
forEach(): Executes a provided function once per array element.
map(): Creates a new array with the results of calling a provided function on every element in this array.
filter(): Creates a new array with all elements that pass the test implemented by the provided function.
reduce(): Applies a function against an accumulator and each element in the array (from left to right) to reduce it to a single value.
some(): Tests whether some element in the array passes the test implemented by the provided function.
every(): Tests whether all elements in the array pass the test implemented by the provided function.
find(): Returns the value of the first element in the array that satisfies the provided testing function.
findIndex(): Returns the index of the first element in the array that satisfies the provided testing function.
includes(): Determines whether an array includes a certain element, returning true or false as appropriate.