This function checks if all items in the list or tuple pass a given test. It returns a boolean value.
Calling this function on an empty array returns true
for any condition!
This function does not generate a change.
array.every(callback)
Argument | Type | Description |
---|---|---|
callback | closure | Closure to execute on each value until the closure evaluates to false. |
Explanation of the callback argument:
Iterable | Arguments | Description |
---|---|---|
array | item, index | Iterate over items in the array. Both item and index are optional. |
Returns true
if every item in the array satisfies the check in the callback function. Otherwise, false
.
This code shows an example using every():
a = [12, 5, 8, 130, 44].every(|x| x >= 10); // false
b = [12, 54, 18, 130, 44].every(|x| x >= 10); // true
// Return both a and b
[a, b];
Return value in JSON format
[
false,
true
]