JS: Iterator.prototype.some
(new in JS: ECMAScript 2025)
iterator.some(f)-
- Return
trueif the function f returntruefor 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.some
// define a generator function function* gf() { for (let x of [5, 4, 8, 6]) yield x; } // call method some console.log(gf().some((x) => x === 8)); // true // call method some console.log(gf().some((x) => x === 99) === 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