[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Iterator/some [Back]  [Original]

Iterator.prototype.some() - JavaScript | MDN

This page was translated from English by the community. Learn more and join the MDN Web Docs community.

View in English Always switch to English

Iterator.prototype.some()

Baseline 2025
Newly available

Since 2025 3, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.

Iterator some() Array.prototype.some() . . .

In this article

js
some(callbackFn)

callbackFn

. , . .

element

.

index

.

callbackFn true, false .

some() callbackFn . true . false . some() true , return() .

. , some() true . callbackFn , .

some()

js
function* fibonacci() {
  let current = 1;
  let next = 1;
  while (true) {
    yield current;
    [current, next] = [next, current + next];
  }
}

const isEven = (x) => x % 2 === 0;
console.log(fibonacci().some(isEven)); // true

const isNegative = (x) => x < 0;
const isPositive = (x) => x > 0;
console.log(fibonacci().take(10).some(isNegative)); // false
console.log(fibonacci().some(isNegative)); //   

some() . . .

js
const seq = fibonacci();
console.log(seq.some(isEven)); // true
console.log(seq.next()); // { value: undefined, done: true }

Specification
ECMAScript 2027 LanguageSpecification
# sec-iterator.prototype.some


Web Proxy Viewer  |  New URL  |  Original Page