JavaScript Array Methods: Full Guide With Clear Examples

Javascript has a rich toolbox of built-in functions that help you transform, search, filter, mutate, and combine arrays in powerful ways.

So in this post, we’ll break down (almost) all array methods, grouped by purpose, with clear tables and easy-to-understand examples—just like the previous guide.

If you missed it, check out the previous post that covers the essentials: 6 Must-Know JavaScript Array Methods (With Simple Examples), it’s a quick read and a perfect intro before diving into this full reference.

Full Array Methods Table

These are the main array methods you’ll encounter, grouped by how they’re typically used:

CategoryMethods
Transformmap, flat, flatMap (flat is handy, but expensive—only use when necessary)
Filter / Subsetfilter, slice (non-mutating), splice (mutating)
Searchfind, findIndex, includes, indexOf, lastIndexOf
Aggregatereduce, reduceRight
IterateforEach, entries, keys, values
Testevery, some
Mutate / Reorderpush, pop, shift, unshift, sort (mutates), reverse, fill, copyWithin
Combineconcat, join
UtilityArray.isArray

Which Method Should You Use?

If you need to…Use…Notes
Transform each itemmap()Same length, new array
Filter or subsetfilter(), slice()slice() is non-mutating
Mutate by removing/insertingsplice()⚠️ Mutates original
Combine or accumulatereduce()Totals, grouping, counting
Flatten nested arraysflat(), flatMap()flatMap() = map + flat
Run side-effectsforEach()No useful return
Check existenceincludes(), indexOf()includes() is clearer
Find something specificfind(), findIndex()Stops early
Reordersort(), reverse()Both mutate
Test conditionsevery(), some()Boolean output
Iterate with index/valueentries(), keys(), values()Returns iterators

Method-by-Method Breakdown

1. Transform

MethodWhat It DoesExample
map()Creates a new array by applying a function to every element.[1, 2, 3].map(n => n * 2) // [2, 4, 6]
flatMap()Maps each element, then flattens the result by one level.[1, 2].flatMap(n => [n, n * 2]) // [1, 2, 2, 4]

2. Filtering Arrays

MethodWhat It DoesExample
filter()Returns a new array with elements that pass a test.[1,2,3,4].filter(n => n % 2 === 0) // [2,4]
find()Returns the first element that matches a condition.[3,6,9].find(n => n > 4) // 6
findIndex()Index of the first matching element.[3,6,9].findIndex(n => n > 4) // 1
findLast()Returns the last matching element.[1,2,3,4].findLast(n => n < 4) // 3
findLastIndex()Index of the last matching element.[1,2,3,4].findLastIndex(n => n < 4) // 2

3. Reducing Arrays

MethodWhat It DoesExample
reduce()Reduces the array to a single value (left → right).[1,2,3].reduce((a,n) => a+n, 0) // 6
reduceRight()Same as reduce but right → left.["a","b","c"].reduceRight((a,c) => a + c) // "cba"

4. Checking Conditions (some, every, includes)

MethodWhat It DoesExample
some()Returns true if at least one item matches.[1,3,5].some(n => n%2 === 0) // false
every()True if all elements match.[2,4,6].every(n => n%2===0) // true
includes()Checks if a value exists in the array.["a","b"].includes("a") // true

5. Sorting & Reordering (sort, reverse, toSorted, toReversed)

MethodWhat It DoesExample
sort()Sorts the array in-place.[3,1,2].sort() // [1,2,3]
reverse()Reverses in-place.[1,2,3].reverse() // [3,2,1]
toSorted()Returns a sorted copy (non-mutating).[3,1,2].toSorted() // [1,2,3]
toReversed()Returns a reversed copy.[1,2,3].toReversed() // [3,2,1]

6. Adding/Removing Items — Mutating

MethodWhat It DoesExample
push()Add to end.arr.push(4)
pop()Remove from end.arr.pop()
shift()Remove from start.arr.shift()
unshift()Add to start.arr.unshift(0)
splice()Add/remove at any position.arr.splice(1,1)

7. Adding/Removing — Non-Mutating

MethodWhat It DoesExample
slice()Extracts a portion without changing the original.[1,2,3].slice(1) // [2,3]
concat()Merges arrays.[1].concat([2,3])
toSpliced()Returns a spliced copy (non-mutating).[1,2,3].toSpliced(1,1) // [1,3]

8. Flattening & Combining

MethodWhat It DoesExample
flat()Flattens nested arrays.[1,[2,[3]]].flat(2) // [1,2,3]
join()Joins items into a string.["a","b"].join("-") // "a-b"

9. Utility Methods

MethodWhat It DoesExample
indexOf()First occurrence index.["a","b","a"].indexOf("a") // 0
lastIndexOf()Last occurrence index.["a","b","a"].lastIndexOf("a") // 2
at()Access by index (supports negatives).[1,2,3].at(-1) // 3
Array.from()Creates an array from iterable or array-like.Array.from("hi") // ["h","i"]
Array.isArray()Checks if value is array.Array.isArray([]) // true
Array.of()Creates an array from arguments.Array.of(1,2) // [1,2]

Final Thoughts

JavaScript’s array methods are incredibly powerful once you understand what each tool is meant for. This post + the previous one give you a full foundation:

  • Core essential methods
  • Full reference of all built-ins
  • Clear examples
  • Grouped usage patterns

Happy learning and thank you for reading!