Standard built-ins
Array.prototype.every()
Returns false at the first falsy predicate result among present indices. Skips ordinary holes; empty input returns true. Use a separate nonempty check when existence matters.
Formal Syntax & Structure
javascript syntaxjavascript
array.every(predicate, thisArg?)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| callback | function | Tests each present value. |
| thisArg | any | Optional this value for ordinary callback functions. |
Return Value
boolean
True when no present element fails.
Working Example
Example Snippetjavascript
console.log([1,2].every(x=>x>0), [].every(x=>false));