Stage 2.7 Draft / March 12, 2026

Iterator Includes

1 Iterator.prototype.includes ( searchElement [ , skippedElements ] )

  1. Let O be the this value.
  2. If O is not an Object, throw a TypeError exception.
  3. Let iterated be the Iterator Record { [[Iterator]]: O, [[NextMethod]]: undefined, [[Done]]: false }.
  4. If skippedElements is undefined, then
    1. Let toSkip be 0.
  5. Else,
    1. If skippedElements is not one of +∞𝔽, -∞𝔽, or an integral Number, then
      1. Let error be ThrowCompletion(a newly created TypeError object).
      2. Return ? IteratorClose(iterated, error).
    2. Let toSkip be the extended mathematical value of skippedElements.
  6. If toSkip < 0, then
    1. Let error be ThrowCompletion(a newly created RangeError object).
    2. Return ? IteratorClose(iterated, error).
  7. Let skipped be 0.
  8. Set iterated to ? GetIteratorDirect(O).
  9. Repeat,
    1. Let value be ? IteratorStepValue(iterated).
    2. If value is done, return false.
    3. If skipped < toSkip, then
      1. Set skipped to skipped + 1.
    4. Else if SameValueZero(value, searchElement) is true, then
      1. Return ? IteratorClose(iterated, NormalCompletion(true)).