The array or array like object of elements to be searched.
A function that accepts up to three arguments of type ArrPredicateCallbackFn or ArrPredicateCallbackFn2. The predicate function is called for each element in the thArray until the predicate returns a value which is coercible to the Boolean value false, or until the end of the array.
Optional
thisArg: anyA value to use as this when executing callbackFn. Defaults to the array if not provided.
true
if the callback function returns a truthy value for at least one element in the array.
Otherwise, false
.
The arrSome() method tests whether at least one element in the array passes the test implemented by the provided function. It returns true if, in the array, it finds an element for which the provided function returns true; otherwise it returns false. It doesn't modify the array.
The arrSome() method is an iterative method. It calls a provided
callbackFn
function once for each element in an array, until thecallbackFn
returns a truthy value. If such an element is found, arrSome() immediately returns true and stops iterating through the array. Otherwise, if callbackFn returns a falsy value for all elements, some() returns false.arrSome() acts like the "there exists" quantifier in mathematics. In particular, for an empty array, it returns false for any condition.
callbackFn
is invoked only for array indexes which have assigned values. It is not invoked for empty slots in sparse arrays.arrSome() does not mutate the array on which it is called, but the function provided as callbackFn can. Note, however, that the length of the array is saved before the first invocation of callbackFn. Therefore:
callbackFn
will not visit any elements added beyond the array's initial length when the call to arrSome() began.callbackFn
, its value passed to thecallbackFn
will be the value at the time that element gets visited. Deleted elements are not visited.Since
0.8.0