JavaScript (ES2026) reference · Array Methods
JavaScript Array some() Method
Return true if at least one element passes a test function. Stops at the first match; an empty array returns false.
JavaScript (ES2026) Since ES5
Syntax
array.some(callbackFn, thisArg)
Parameters
| Parameter | Description |
|---|---|
callbackFn |
Called for each element with (element, index, array). |
Return value
true or false.
Examples
const nums = [1, 3, 8];
console.log(nums.some((n) => n % 2 === 0), nums.some((n) => n > 10));
Output
true false
const users = [{ role: "user" }, { role: "admin" }];
console.log(users.some((u) => u.role === "admin"));
Output
true
Version history
| Version | Change |
|---|---|
| JavaScript ES5 | Added |
In other languages
any()· Python
Related
array.every()· Return true if every element passes a test function. Stops at the first failure; an empty array returns true.array.find()· Return the first element that passes a test function, or undefined if none does.array.includes()· Return true if the array contains a value, using SameValueZero equality (so it finds NaN, unlike indexOf).- JavaScript Arrays · tutorial
- JavaScript Array Methods · tutorial