Random Picture

photo by Alexander Mass on Unsplash

1. To mutate the original array

add to original array

.push() - add to the end

.unshift() - add to the beginning

remove from original array

.pop() - remove from the end

.shift() - remove from the beginning

.splice() - remove from anywhere


.reverse() - reverse the array

.sort() - sort the array

.fill() - fill the array with a certain value

2. To create a new array

with the original array

.map() - transform the array

.filter() - filter the array

.slice() - slice the array

.concat() - merge two arrays

.flat() - flatten the array

.flatMap() - map and then flatten

3. With an array index

based on value

.indexOf() - find index of an element

based on test condition

.findIndex() - find index of an element

4. With an array element

based on test condition

.find() - find an element

5. To know if array includes something

based on value

.includes() - includes an element

based on test condition

.some() - if at least one element satisfies the condition

.every() - if all elements satisfy the condition

6. With a new string

based on the separator string

.join() - join the array into a string

7. To transform the value

based on the accumulator

.reduce() - reduce the array to a single value

8. To loop over the array

based on callback

.forEach() - loop over the array (does not create a new array)

Summary Table

Illustration by Jonas Schmedtmann Credit: Jonas Schmedtmann