JavaScript (ES2026) reference · Array Methods
JavaScript Array every() Method
Return true if every element passes a test function. Stops at the first failure; an empty array returns true.
JavaScript (ES2026) Since ES5
Syntax
array.every(callbackFn, thisArg)
Parameters
| Parameter | Description |
|---|---|
callbackFn |
Called for each element with (element, index, array). |
Return value
true or false.
Examples
const ages = [21, 34, 19];
console.log(ages.every((age) => age >= 18));
console.log(ages.every((age) => age >= 21));
Output
true false
console.log([].every((x) => x > 100)); // true: nothing failed
Output
true
Version history
| Version | Change |
|---|---|
| JavaScript ES5 | Added |
In other languages
all()· Python
Related
array.some()· Return true if at least one element passes a test function. Stops at the first match; an empty array returns false.array.filter()· Return a new array with only the elements that pass a test function. The original array is not changed.array.find()· Return the first element that passes a test function, or undefined if none does.- JavaScript Arrays · tutorial
- JavaScript Array Methods · tutorial