Array.prototype.some

Determines whether the predicate function returns true for any element of an array.

Syntax

some(predicate, thisArg?)

Parameters

Return value

Returns true if a predicate returns true for any element, false otherwise.

Example

[4, 5, 6].some(x => x % 2 === 0)
true
[1, 3, 5].some(x => x % 2 === 0)
false
["moose", "monkey", "cat"].some(s => s.startsWith("mo"))
true
["coffee", "tea", "milk"].some(drink => drink.includes("a"))
true
["coffee", "tea", "milk"].some(drink => drink.includes("u"))
false

See also