Array.prototype.some()

Tests whether at least one element passes the provided testing function.

Since ES5 Spec ↗

Syntax

arr.some(callback, thisArg)

Parameters

NameTypeRequiredDescription
callback Function Yes Predicate called with (element, index, array). Return truthy to indicate a match.
thisArg any No Value to use as `this` when executing the callback.

Returns

boolean — true if the callback returns truthy for any element; otherwise false.

Examples

console.log([1, 2, 3].some(n => n > 2));
Output
true
console.log([].some(n => n > 0));
Output
false

Notes

Short-circuits and returns true on the first match. Returns false for an empty array. Use `every` to require all elements to pass.

Browser & runtime support

EnvironmentSince version
chrome 1.0
firefox 1.5
safari 3.0
edge 12
node 0.10

See also