some

This function checks if at least one item in the list or tuple passes a given test. It returns a boolean value.

Calling this function on an empty array returns false for any condition!

This function does not generate an event.

Function

array.some(callback)

Arguments

Argument Type Description
callback closure Closure to execute on each value until the closure evaluates to true.

Explanation of the callback argument:

Iterable Arguments Description
array item, index Iterate over items in the array. Both item and index are optional.

Return value

Returns true if at least one item in the array satisfies the check in the callback function. Otherwise, false.

Example

This code shows an example using find():

a = [2, 5, 8, 1, 4].some(|x| x >= 10);   // false
b = [12, 5, 8, 1, 4].some(|x| x >= 10);  // true

// Return both a and b
[a, b];

Return value in JSON format

[
    false,
    true
]