New to Rust? Grab our free Rust for Beginners eBook Get it free →
JavaScript Array some() method explained with examples

The array some() method in JavaScript checks whether at least one element in an array passes a test you define. It returns true the moment it finds a match and stops. It never checks the rest. That early-exit behavior makes it faster than looping through everything yourself and the intent is immediately clear to anyone reading the code.
This article covers the syntax, parameters, how .some() works internally, practical examples and a direct comparison with every(), find() and filter() so you know which method to reach for.
Syntax of some()
arr.some(callback(element, index, array), thisArg);
Parameters:
- callback: the test function run against each element.
- element: the current element being processed.
- index: the index of the current element (optional).
- array: the array
some()was called on (optional). - thisArg: optional value to use as
thisinside the callback. Defaults toundefined.
Return value: true if any element passes the callback test. false if none do. For an empty array, always false.
How some() works
some() iterates the array from left to right, calling the callback once per element. As soon as the callback returns a truthy value, some() immediately returns true and stops. If it reaches the end without a truthy result, it returns false.
The array length is fixed before iteration begins. Elements added beyond that length during iteration are not visited. Elements deleted before being visited are skipped. Changes to already-visited indexes are ignored.
Here is the basic working example:
const numbers = [5, 10, 15, 20, 25];
function check(num){
return num > 20;
}
console.log(numbers.some(check));
The array has 25, which satisfies num > 20, so some() returns true.

Now change the threshold to 30:
const numbers = [5, 10, 15, 20, 25];
function check(num){
return num > 30;
}
console.log(numbers.some(check));
No element exceeds 30, so some() returns false.

If you want to better understand arrays before going further, the JavaScript array guide on CodeForGeek covers how arrays are created, accessed and iterated in depth.
Examples of some()
Example 1
Check whether any string in an array has more than 4 characters.
const animals = ["Tiger", "Dog", "Cat"];
const flowers = ["Rose", "Lily"];
function check(str){
return str.length > 4;
}
console.log("Condition check for animal array",animals.some(check));
console.log("Condition check for flower array",flowers.some(check));
animals contains “Tiger” (5 characters), so the method returns true. flowers has “Rose” (4) and “Lily” (4), both exactly 4 and neither exceeds 4, so false.

Example 2
Test a single number array against three different predicates: even, prime and palindrome.
const numbers = [17, 15, 11, 13];
function checkEven(num){
return num % 2 === 0;
}
function checkPrime(num) {
if (num <= 1) return false;
for (let i = 2; i <= Math.sqrt(num); i++) {
if (num % i === 0) return false;
}
return true;
}
function checkPalindrome(num) {
const str = num.toString();
const reversedStr = str.split('').reverse().join('');
return str === reversedStr;
}
console.log("Array has an even number",numbers.some(checkEven));
console.log("Array has a Prime number",numbers.some(checkPrime));
console.log("Array has a Palindrome number",numbers.some(checkPalindrome));
All four numbers are odd, so checkEven returns false. 17, 11 and 13 are prime, so checkPrime returns true. 11 reversed is still 11, so checkPalindrome also returns true.

Example 3
Check an array of customer objects for a role value.
const costumers = [
{ name: "Monica", role: "user" },
{ name: "Rachel", role: "user" },
{ name: "Ross", role: "admin" },
{ name: "Joey", role: "user" }
];
function checkAdmin(person){
return person.role === "admin";
}
function checkIntruder(person){
return person.role === "intruder";
}
console.log("Group has admin in it",costumers.some(checkAdmin));
console.log("Group has intruder in it",costumers.some(checkIntruder));
Ross has the admin role, so checkAdmin returns true. No one has the intruder role, so checkIntruder returns false.

some() with arrow functions
Arrow functions are the most common shorthand for the callback. They work well for stateless tests where you don’t need this:
const prices = [12, 8, 45, 3, 22];
// Check if any price exceeds 40
const hasExpensive = prices.some(price => price > 40);
console.log(hasExpensive); // true
// Check availability of a value (mimicking includes())
const fruits = ["apple", "banana", "mango", "guava"];
const hasBanana = fruits.some(fruit => fruit === "banana");
console.log(hasBanana); // true
Arrow functions are fine here because neither test references this. When you do need this, such as when the threshold lives outside the callback, use a named function or a function expression instead. Arrow functions don’t have their own this binding, so passing thisArg has no effect on them.
some() with the thisArg argument
thisArg lets you inject an external object into the callback’s this context. This is useful when the condition parameters belong to a shared configuration object rather than being hardcoded inside the callback.
Say you want a reusable divisibility check where the divisor can change:
const numbers = [1, 2, 3, 4, 5];
function divisible(element) {
return element % this.divisor === 0;
}
const hasEven = numbers.some(divisible, { divisor: 2 });
const hasDivisibleByThree = numbers.some(divisible, { divisor: 3 });
const hasDivisibleBySeven = numbers.some(divisible, { divisor: 7 });
console.log(hasEven); // true
console.log(hasDivisibleByThree); // true
console.log(hasDivisibleBySeven); // false
The same divisible callback works for any divisor without modification. You just swap the thisArg.
Why arrow functions break thisArg: Arrow functions inherit this from their lexical scope, so whatever you pass as thisArg is ignored. The callback will read from the surrounding scope, not from the injected object. Always use a named function or anonymous function expression when you need thisArg to work.
some() on sparse arrays and array-like objects
some() skips empty slots in sparse arrays. This is a subtlety that catches people off guard:
// sparse array: index 1 is empty
console.log([1, , 3].some(x => x === undefined)); // false
console.log([1, , 1].some(x => x !== 1)); // false
console.log([1, undefined, 1].some(x => x !== 1)); // true
The second example is false because the empty slot at index 1 is never visited. The third example is true because undefined is explicitly stored at index 1 and is visited.
some() also works on any object with a length property and integer-keyed values:
const arrayLike = {
length: 3,
0: "a",
1: "b",
2: "c",
3: 99, // ignored because length is 3
};
console.log(Array.prototype.some.call(arrayLike, x => typeof x === "number")); // false
The value 99 at index 3 is beyond the declared length so it’s never checked. This matters when you’re working with DOM NodeLists or arguments objects.
some() with large arrays: performance notes
The early-exit behavior of some() is what makes it efficient at scale. As soon as a match is found, iteration stops.
const largeArray = Array.from({ length: 100000 }, (_, i) => i);
// Stops as soon as it reaches 50001
const hasNumberAbove50000 = largeArray.some(num => num > 50000);
console.log(hasNumberAbove50000); // true
If the matching element appears near the start of the array, some() can be dramatically faster than a filter() or forEach() loop that runs to completion.
Keep your callback simple. some() calls it on each element until a match is found. A complex callback slows each call. If the test involves multiple async checks or heavy computation, rethink the approach.
const users = [
{ id: 0, active: false },
{ id: 1, active: false },
{ id: 2, active: true },
// ... thousands more
];
// Stops as soon as it hits id:2
const hasActiveUser = users.some(user => user.active);
console.log(hasActiveUser); // true
When you genuinely need to process every element, such as collecting all matches, summing values or applying side effects, filter() or forEach() is the right choice. some() is not a general iteration tool. It’s a short-circuit existence check.
some() vs every() vs find() vs filter()
These four methods all accept a callback and iterate the array, but their return values and use cases differ. If you’re removing duplicate values from an array rather than searching it, the guide on removing duplicates from a JavaScript array covers the right tools for that job.
| Method | Returns | Stops early? | Use when |
|---|---|---|---|
some() | true / false | Yes, on first match | You need to know if at least one element passes |
every() | true / false | Yes, on first failure | You need to confirm all elements pass |
find() | The element or undefined | Yes, on first match | You need the actual matching element |
filter() | New array | No | You need all matching elements |
some() as an existence check
const users = [
{ name: "Alice", age: 20 },
{ name: "Bob", age: 30 },
{ name: "Sarah", age: 19 },
];
const anyOver25 = users.some(user => user.age > 25);
console.log(anyOver25); // true, stops at Bob
every() as an all-pass check
const ages = [18, 22, 30];
const allAdults = ages.every(age => age >= 18);
console.log(allAdults); // true
If even one element fails the test, every() returns false immediately.
find() to retrieve the match
const firstOver25 = users.find(user => user.age > 25);
console.log(firstOver25); // { name: "Bob", age: 30 }
find() gives you the element itself. The JavaScript array find() method guide covers find(), findIndex(), findLast() and findLastIndex() in depth.
filter() to collect all matches
const allOver18 = users.filter(user => user.age > 18);
console.log(allOver18); // [ { name: "Alice", age: 20 }, { name: "Bob", age: 30 } ]
filter() always runs to the end and returns a new array. Use it when you need all matches, not just whether one exists.
A practical rule: if the question is “does any element satisfy X?” use some(). If the question is “which element satisfies X?” use find(). If the question is “do all elements satisfy X?” use every(). If the question is “give me every element that satisfies X” use filter().
Checking if an array contains a value
Before .includes() was standardized, .some() was the idiomatic way to check for a value in an array. It’s still useful when the check is more complex than strict equality:
const fruits = ["apple", "banana", "mango", "guava"];
// Using some() to check for a value
function checkAvailability(arr, val) {
return arr.some(arrVal => val === arrVal);
}
console.log(checkAvailability(fruits, "grapefruit")); // false
console.log(checkAvailability(fruits, "banana")); // true
For simple scalar checks, includes() is shorter. Use some() when the predicate needs to do more work, such as checking nested object properties, combining conditions or applying a conversion before comparing.
Mistakes developers make
Not returning a value from the callback
The callback must return a truthy or falsy value. If it returns nothing, some() treats every element as failing the test and always returns false.
// Wrong: callback never returns anything
function checkValue(num) { num > 10; }
console.log([5, 15].some(checkValue)); // false (wrong answer)
// Right
function checkValue(num) { return num > 10; }
console.log([5, 15].some(checkValue)); // true
Assuming some() visits every element
some() stops as soon as it finds a match. If your callback has side effects such as logging, counting or mutating state, those effects only run for elements visited before the match. If you need every element processed regardless, use forEach().
Calling some() on an empty array
some() always returns false for an empty array because there are no elements to evaluate. This is mathematically correct but can surprise you if the array comes from an API that sometimes returns an empty list.
console.log([].some(x => x > 0)); // false
Check that the array is non-empty before drawing conclusions from the result when that distinction matters for your logic.
Using arrow functions with thisArg
As covered above, arrow functions ignore thisArg. If you pass an arrow function and a second argument to some(), the second argument is silently discarded. Use a named or anonymous function expression when you need this to work.
// thisArg is ignored here since arrow function has no this binding
const wrong = [1, 2, 3].some(n => n % this.divisor === 0, { divisor: 2 });
// Named function correctly receives thisArg
function divisible(n) { return n % this.divisor === 0; }
const right = [1, 2, 3].some(divisible, { divisor: 2 });
console.log(right); // true
Key takeaways
some()returnstrueif any element in the array passes the callback test andfalseotherwise.- It short-circuits: iteration stops as soon as a match is found, which makes it efficient for large arrays.
- For an empty array,
some()always returnsfalseregardless of the test. some()does not mutate the original array.- Arrow functions do not bind
this, sothisArghas no effect when the callback is an arrow function. some()skips empty slots in sparse arrays and only explicitly stored values are tested.- The callback must return a value. A missing
returnmeanssome()always receivesfalsefrom that callback. - Use
every()to confirm all elements pass,find()to retrieve the first match andfilter()to collect all matches.
Frequently asked questions (FAQ)
What does the JavaScript some() method do?
It checks if at least one element in an array passes the test in the callback function and returns true if found and false if none match.
Does some() stop after finding the first match?
Yes. some() short-circuits immediately when the callback returns a truthy value and does not continue iterating the rest of the array.
What does some() return for an empty array?
It always returns false for an empty array because there are no elements to evaluate.
Can I use some() to check if an array includes a value?
Yes. Write a callback that compares each element to the target value. For simple equality, includes() is shorter but some() handles complex conditions that includes() cannot.
Does some() change the original array?
No. some() does not modify the array it is called on. It only reads each element.
Why does thisArg not work with my arrow function callback?
Arrow functions do not have their own this binding. They inherit this from the surrounding scope, so whatever you pass as thisArg is ignored. Use a named or anonymous function expression instead.
When should I use some() instead of every()?
Use some() when you want to know if at least one element passes a test. Use every() when you need all elements to pass.
How is some() different from find()?
some() returns a boolean. find() returns the first element that matches. Use find() when you need the actual value, not just a yes or no answer.
Final conclusion
The .some() method is one of those array tools that makes code both shorter and easier to read. Once you internalize when to choose it over every(), find() or filter(), you’ll find yourself reaching for it naturally in validation logic, permission checks and search conditions.




