JS: Iterator.prototype.some
(new in ECMAScript 2025)
iterator.some(f)-
- Return
trueif the function f returntruefor every yield in Iterator Object iterator. - As soon as f return
false, exit the iteration and returnfalse, and set the iterator to no more yield.
f is passed args: currentElement, currentIndex.
similar to Array.prototype.some
// define a generator function function* gf() { for (let x of [5, 4, 8, 6]) yield x; } // call method some console.assert( gf().some((x) => x === 8) === true, ); // call method some console.assert( gf().some((x) => x === 99) === false, ); - Return