Array.prototype.some()
some(callbackFn) Returns:
boolean · Added in vES5 · Updated March 13, 2026 · Array Methods array some iteration
some() tests whether at least one element in the array passes the test implemented by the provided function. It returns true if it finds an element for which the function returns true, otherwise false.
Syntax
some(callbackFn)
some(callbackFn, thisArg)
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
callbackFn | function | — | Function to test each element. Called with (element, index, array). |
thisArg | any | undefined | Value to use as this when executing callbackFn. |
The callback function should return a truthy value to indicate the element passes the test.
Examples
Basic usage
const numbers = [1, 2, 3, 4, 5];
// Check if any element is greater than 3
const hasLargeNumber = numbers.some(n => n > 3);
console.log(hasLargeNumber);
// true
// Check if any element is negative
const hasNegative = numbers.some(n => n < 0);
console.log(hasNegative);
// false
Finding the first matching element
const users = [
{ name: 'Alice', active: false },
{ name: 'Bob', active: true },
{ name: 'Charlie', active: false }
];
const hasActiveUser = users.some(user => user.active);
console.log(hasActiveUser);
// true
Using with strings
const words = ['apple', 'banana', 'cherry', 'date'];
// Check if any word starts with 'c'
const hasCWord = words.some(word => word.startsWith('c'));
console.log(hasCWord);
// true
// Check if any word is longer than 10 characters
const hasLongWord = words.some(word => word.length > 10);
console.log(hasLongWord);
// false
Common Patterns
Validating form data
const formFields = [
{ name: 'email', value: '', required: true },
{ name: 'username', value: 'john', required: true },
{ name: 'bio', value: 'Hello', required: false }
];
const hasEmptyRequired = formFields.some(field =>
field.required && !field.value
);
console.log(hasEmptyRequired);
// true - email is empty but required
Checking permissions
const userRoles = ['guest', 'reader', 'contributor'];
// Define required permissions
const requiredPermissions = ['admin', 'editor', 'owner'];
// Check if user has any elevated permission
const hasElevatedRole = userRoles.some(role =>
requiredPermissions.includes(role)
);
console.log(hasElevatedRole);
// false
Early termination
// some() short-circuits - stops after finding first match
const largeArray = Array.from({ length: 1000000 }, (_, i) => i);
const start = performance.now();
const found = largeArray.some(n => n > 500);
const end = performance.now();
console.log(found);
// true
console.log('Stopped after finding match');
// Stops iterating at 501 - very efficient!
See Also
- array::every - Tests if all elements pass
- array::find - Returns the first matching element
- array::filter - Returns all matching elements
- array::includes - Tests for value inclusion