some() returns true if at least one element of an array passes a test; every() returns true only if all of them do. Both take a callback, both return a boolean, and both stop as soon as the answer is known. They replace a common pattern of looping with a flag, and they read as English. The one surprise is what they return for an empty array, covered below.
The two functions#
const ages = [12, 19, 34];
ages.some(a => a >= 18); // true: at least one adult
ages.every(a => a >= 18); // false: not everyone is
The callback receives each element (and, if you want them, the index and the array) and returns true or false. some is an OR across the results; every is an AND.
They stop early#
[1, 2, 3, 4].some(n => { console.log(n); return n > 1; });
// logs 1, 2 - stops at the first true
[1, 2, 3, 4].every(n => { console.log(n); return n < 2; });
// logs 1, 2 - stops at the first false
some returns at the first true; every at the first false. That makes them efficient for large arrays and means the callback must not rely on being called for every element.
Empty arrays#
[].some(x => true); // false
[].every(x => false); // true
With nothing to test, some found no element that passes, so false. every found no element that fails, so true. This is the mathematical convention (a statement about all members of an empty set is vacuously true), and it bites in validation: items.every(isValid) on an empty cart returns true. Check the length separately when empty must mean invalid.
Everyday uses#
// Validation: all fields filled?
const complete = Object.values(form).every(v => v.trim() !== '');
// Permissions: does the user have any of these roles?
const canEdit = user.roles.some(r => ['admin', 'editor'].includes(r));
// Data checks: any order still open?
const hasPending = orders.some(o => o.status === 'pending');
// Nested: does every team have at least one lead?
const staffed = teams.every(t => t.members.some(m => m.isLead));
The last example is the pattern to notice: nesting every and some expresses “for all X there exists a Y” in one readable line.
Compared with the loop they replace#
// Before
let anyAdult = false;
for (const a of ages) {
if (a >= 18) { anyAdult = true; break; }
}
// After
const anyAdult = ages.some(a => a >= 18);
Same behaviour, including the early exit, with no flag variable to get wrong.
When to use something else#
| You want | Use |
|---|---|
| Whether a specific value is present | includes(value) |
| The first element that matches | find(fn), or findIndex |
| All elements that match | filter(fn) |
| Whether any match, given a condition | some(fn) |
| Whether all match | every(fn) |
includes is some with an equality test, and reads better when that is all you need. find returns the element rather than a boolean; if you would use some and then search again for the item, use find once and check for undefined.
Negation#
!items.some(isBroken) // none are broken
items.every(i => !isBroken(i)) // the same thing, read the other way
Both are correct. Choose the one that matches how you would say it: “none are broken” reads as the first.
Questions people ask#
Do some and every work on objects?
Not directly; they are array methods. Use Object.values(obj).some(...) or Object.entries.
Can the callback be async?
Not usefully: an async function returns a promise, which is always truthy, so some returns true immediately. Use Promise.all with map, then some on the results.
Are they available on iterators and Sets?
Iterator helpers add some and every to iterators in current engines. For a Set, spread it into an array or use Iterator.from(set).
Which is faster, some or a for loop?
Equivalent in practice; both stop early. Readability is the reason to choose some.
Where to go next#
- JavaScript array methods reference — the whole family.
- Arrays and objects in JavaScript — the data these run on.
- What’s new in JavaScript in 2026 — including iterator helpers.