Array.prototype.every()
Array.prototype.every() is a JavaScript method in the Array category. Tests whether all elements pass the test. The syntax is array.every(callbackFn, thisArg). It returns true if all elements pass the test, otherwise false. A typical example: [1, 2, 3].every(x => x > 0) // true. Another practical use — Validate all values: const ages = [22, 25, 30, 18] const allAdult = ages.every(a => a >= 18) console.log(allAdult) // true Its time complexity is O(n), which matters when it runs over large inputs. The TypeScript signature is (predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): boolean. A close sibling is Array.prototype.map(), which creates a new array populated with the results of calling a provided function on every element. A close sibling is Array.prototype.filter(), which creates a new array with all elements that pass the test implemented by the provided function. A close sibling is Array.prototype.reduce(), which executes a reducer function on each element, resulting in a single output value.