Reference / JavaScript
Array.prototype.every()
Tests whether all elements in the array pass the test implemented by the provided function.
Syntax
every(predicate: (value: T, index: number, array: T[]) => boolean): booleanParameters
| Name | Type | Description |
|---|---|---|
| predicate | Function | Condition tester function. |
Examples
Check if all numbers are positive
const numbers = [10, 20, 30];
console.log(numbers.every(n => n > 0)); // trueReturns true for any condition on an empty array (vacuous truth).