JS: Iterator.prototype.every
(new in JS: ECMAScript 2025)
iterator.every(f)
-
- Return
true
if the function f returntrue
for every yield in Iterator iterator. - As soon as f return
false
, exit the iteration and returnfalse
, and set the iterator to no more yield.
Normally you can use this method on any Iterable, because all standard iterable objects are also Iterator.
- f is given args:
- currentElement
- currentIndex
similar to JS: Array.prototype.every
// define a generator function function* gf() { for (let x of [0, 1, 2, 3]) yield x; } // check if every item is less than 5 console.log(gf().every((x) => x < 5)); // true // check if every item is less than 3 console.log(gf().every((x) => x < 3) === false); // true
- Return
JavaScript. iterator helpers
- JS: Iterator.prototype.map
- JS: Iterator.prototype.forEach
- JS: Iterator.prototype.filter
- JS: Iterator.prototype.reduce
- JS: Iterator.prototype.take
- JS: Iterator.prototype.drop
- JS: Iterator.prototype.every
- JS: Iterator.prototype.some
- JS: Iterator.prototype.find
- JS: Iterator.prototype.flatMap
- JS: Iterator.prototype.toArray