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:
| Category | Methods |
|---|
| Transform | map, flat, flatMap (flat is handy, but expensive—only use when necessary) |
| Filter / Subset | filter, slice (non-mutating), splice (mutating) |
| Search | find, findIndex, includes, indexOf, lastIndexOf |
| Aggregate | reduce, reduceRight |
| Iterate | forEach, entries, keys, values |
| Test | every, some |
| Mutate / Reorder | push, pop, shift, unshift, sort (mutates), reverse, fill, copyWithin |
| Combine | concat, join |
| Utility | Array.isArray |
Which Method Should You Use?
| If you need to… | Use… | Notes |
|---|
| Transform each item | map() | Same length, new array |
| Filter or subset | filter(), slice() | slice() is non-mutating |
| Mutate by removing/inserting | splice() | ⚠️ Mutates original |
| Combine or accumulate | reduce() | Totals, grouping, counting |
| Flatten nested arrays | flat(), flatMap() | flatMap() = map + flat |
| Run side-effects | forEach() | No useful return |
| Check existence | includes(), indexOf() | includes() is clearer |
| Find something specific | find(), findIndex() | Stops early |
| Reorder | sort(), reverse() | Both mutate |
| Test conditions | every(), some() | Boolean output |
| Iterate with index/value | entries(), keys(), values() | Returns iterators |
Method-by-Method Breakdown
| Method | What It Does | Example |
|---|
| 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
| Method | What It Does | Example |
|---|
| 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
| Method | What It Does | Example |
|---|
| 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)
| Method | What It Does | Example |
|---|
| 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)
| Method | What It Does | Example |
|---|
| 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
| Method | What It Does | Example |
|---|
| 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
| Method | What It Does | Example |
|---|
| 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
| Method | What It Does | Example |
|---|
| 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
| Method | What It Does | Example |
|---|
| 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!