Standard built-ins

Array.prototype.every()

Try the free JavaScript compiler

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

NameTypeDescription
callbackfunctionTests each present value.
thisArganyOptional 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));
JavaScript Reference