JavaScript arrays are powerful — but with so many methods, it’s easy to forget what’s what. Here’s a 2025-ready cheat sheet to bookmark. 🔖
🔄 Transformation
-
map()→ Transform each element -
filter()→ Keep elements that match a condition -
reduce()→ Reduce array to single value -
flat()→ Flatten nested arrays -
flatMap()→ Map + flatten in one step
🔍 Searching
-
find()→ First element matching condition -
findIndex()→ Index of first match -
includes()→ Check if array contains a value -
indexOf()→ First index of a value -
lastIndexOf()→ Last index of a value
✂️ Adding & Removing
-
push()→ Add to end -
pop()→ Remove from end -
shift()→ Remove from start -
unshift()→ Add to start -
splice()→ Add/remove anywhere
🧹 Utility
-
forEach()→ Loop through elements -
every()→ Check if all elements match condition -
some()→ Check if at least one matches -
sort()→ Sort elements (watch out for lexicographic sort!) -
reverse()→ Reverse array
🆕 2025+ Additions
-
toSorted()→ Immutable sort (doesn’t mutate original array) -
toReversed()→ Immutable reverse -
toSpliced()→ Immutable splice -
with()→ Immutable element replacement
js
const arr = [1, 2, 3];
const newArr = arr.with(1, 99);
// [1, 99, 3] → arr stays unchanged
Top comments (1)
Check me account for more cool stuff.