Master programming syntax, solve interactive challenges & run live code in Syntaxis Explore Arena →
Reference / JavaScript

Array.prototype.some()

Tests whether at least one element in the array passes the test implemented by the provided function.

Syntax
some(predicate: (value: T, index: number, array: T[]) => boolean): boolean

Parameters

NameTypeDescription
predicateFunctionCondition tester function.

Examples

Check if any item is even
const nums = [1, 3, 5, 8];
const hasEven = nums.some(n => n % 2 === 0);
console.log(hasEven); // true
Returns false for any condition on an empty array.