Developer December 22, 2025

6 JavaScript Array Methods You Keep Forgetting (With Examples That Stick)

You've used filter and map a hundred times. But these six methods solve specific problems you're probably handling the hard way.

You know map, filter, and forEach. They’re muscle memory at this point. But JavaScript arrays have methods for specific situations that most developers either forget exist or never learned in the first place.

Here are six that solve real problems—with examples you’ll actually remember.

1. find() — Get the First Match

Stop filtering an array just to grab the first result.

// The hard way
const users = [{ id: 1, name: 'Alex' }, { id: 2, name: 'Sam' }];
const user = users.filter(u => u.id === 2)[0];

// The right way
const user = users.find(u => u.id === 2);
// { id: 2, name: 'Sam' }

Why it matters: filter loops through the entire array. find stops at the first match. For large arrays, that’s real performance.

Returns: The first matching element, or undefined if none found.

2. findIndex() — Get the Position

Same as find, but returns the index instead of the element.

const tasks = ['email', 'meeting', 'code review', 'lunch'];
const meetingIndex = tasks.findIndex(t => t === 'meeting');
// 1

// Useful for: "Is this item before or after that one?"
if (meetingIndex < tasks.findIndex(t => t === 'lunch')) {
  console.log('Meeting is before lunch');
}

Returns: The index of the first match, or -1 if not found.

3. some() — Does Any Match?

Check if at least one element passes a test.

const cart = [
  { name: 'Shirt', inStock: true },
  { name: 'Pants', inStock: false },
  { name: 'Hat', inStock: true }
];

const hasOutOfStock = cart.some(item => !item.inStock);
// true

The pattern: “Does any item meet this condition?”

Why not filter? You don’t care which items—you just need a yes/no answer. some short-circuits on the first match.

4. every() — Do All Match?

The opposite of some. Check if every element passes.

const form = [
  { field: 'email', valid: true },
  { field: 'password', valid: true },
  { field: 'name', valid: false }
];

const isFormValid = form.every(f => f.valid);
// false

The pattern: “Do all items meet this condition?”

Short-circuits: Stops at the first failure. A 10,000-item array where item #3 fails? It only checks 3 items.

5. includes() — Is This Value In Here?

For simple “does it exist?” checks, stop using indexOf.

// The old way
if (fruits.indexOf('apple') !== -1) { ... }

// The readable way
if (fruits.includes('apple')) { ... }

Caveat: Only works for primitive values. For objects, use some():

// Won't work (object reference comparison)
[{ id: 1 }].includes({ id: 1 }); // false

// Use this instead
[{ id: 1 }].some(item => item.id === 1); // true

6. flat() — Flatten Nested Arrays

Got arrays inside arrays? Flatten them.

const nested = [[1, 2], [3, 4], [5, 6]];
nested.flat();
// [1, 2, 3, 4, 5, 6]

// Deeply nested? Specify depth
const deep = [1, [2, [3, [4]]]];
deep.flat(2);
// [1, 2, 3, [4]]

// Just flatten everything
deep.flat(Infinity);
// [1, 2, 3, 4]

Real-world use: Fetching data from multiple sources that each return arrays, then combining them into one list.

The Decision Tree

SituationMethod
”Get the first one that matches”find()
”Where is the first match?”findIndex()
”Does any item match?”some()
”Do all items match?”every()
”Is this exact value in here?”includes()
”Combine nested arrays”flat()

These aren’t obscure methods—they’re in every modern browser and Node.js. The only reason you’re not using them is nobody showed you when to reach for them.

Now you know.


Want 100 practical tips like this for HTML, CSS, and JavaScript? 100 Coding for Website Design Tips covers modern web development one concept at a time—perfect for designers and developers who learn by doing.

Want more tips like this?

Our book contains 100+ practical tips just like this—one concept per page, ready to use immediately.

Check out 100 Coding for Website Design Tips