some()

ES5+

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

Syntax

array.some(callback(element, index, array), thisArg)

Parameters

callback Function

Function to test each element

Return Value

boolean

true if at least one element passes the test

Examples

JavaScript
const numbers = [1, 2, 3, 4, 5];
const hasEven = numbers.some(x => x % 2 === 0);
console.log(hasEven);
Output:
// true

Related Methods