Array Methods for Searching and Iteration in JavaScript

A practical reference for find, findIndex, includes, some, every, filter, map, and reduce — when to reach for each one.

By DevStudio Online Team · Published September 3, 2026

JavaScript has more array iteration methods than most people use, and mixing them up leads to code that works but reads badly. Here's what each one is actually for.

Searching for a single item

const users = [{ id: 1, name: 'Ana' }, { id: 2, name: 'Ravi' }]
 
users.find(u => u.id === 2)        // { id: 2, name: 'Ravi' } — the item itself
users.findIndex(u => u.id === 2)   // 1 — its position
users.includes(users[0])           // true — reference/value equality check

Use find when you want the object; findIndex when you need to splice or track position; includes only for primitive values or when you already have the exact reference.

Testing the whole array

const ages = [22, 34, 19, 41]
 
ages.some(a => a < 21)   // true  — at least one match
ages.every(a => a >= 18) // true  — all match

some and every return a single boolean and stop iterating as soon as the answer is known — they're the right tool when you don't actually need the matching items, just a yes/no.

Transforming vs. reducing

const prices = [10, 20, 30]
 
prices.filter(p => p > 15)              // [20, 30] — a subset
prices.map(p => p * 1.1)                // [11, 22, 33] — same length, transformed
prices.reduce((sum, p) => sum + p, 0)   // 60 — collapsed to one value

The mistake to avoid is reaching for reduce to build a new array or object when map/filter already say what you mean more clearly — reduce is for genuinely collapsing a list into something smaller, like a sum, a max, or a grouped object.

Quick decision guide

  • Need one matching item? find
  • Need one matching index? findIndex
  • Need a yes/no across the array? some / every
  • Need a smaller list? filter
  • Need the same list, changed? map
  • Need a single accumulated value? reduce

Related tool

JS Playground — try this live

More JavaScript guides