iterator.includes(searchElement) walks the iterator and asks: is this value equal to the one I am looking for? If a match is found, the result is true. If the iterator ends with no match, the result is false.
Equality uses SameValueZero: like ===, except NaN equals NaN, and 0 equals -0. The method consumes the iterator, even when it finds a match early.
Remember
iterator.includes(value)
iterator.includes(value, fromIndex)
found → true (stops early)
not found → false
SameValueZero: NaN equals NaN, 0 equals -0
Consumes the iterator (it is closed after the call).
Syntax
Call it on an iterator and pass the value to search for. You can also skip the first few values with fromIndex.
// Newer Iterator helper
Iterator.prototype.includes(searchElement)
Iterator.prototype.includes(searchElement, fromIndex)
// searchElement : value to look for
// fromIndex : optional non-negative start index (default 0)
// returns : true or false
Parameters
Parameter
Description
searchElement
Required. The value to look for. Compared with each yielded value using SameValueZero (NaN matches NaN, 0 matches -0).
fromIndex
Optional. How many values to skip before searching. Must be a non-negative integer, Infinity, or undefined (treated as 0). Negative numbers are not allowed.
Return Value
Return Value
Description
boolean
true if a matching value is found (after any skipped values). false if the iterator ends without a match. The iterator is closed either way.
JavaScript Examples
Example 1 — Check Whether a Value Is Present
Ask if the number 3 appears in an iterator of 1 through 5.
The Try It page first checks that iterator.includes() exists, because Iterator helpers are still new. In an older browser it prints a short explanation and the output above. In a current browser it runs the code for real.
How It Works
Make an iterator.[1, 2, 3, 4, 5].values() yields each number.
Search for 3. 1 and 2 do not match; 3 does.
Result is true. The search stops at the match, and the iterator is closed.
The Try It page first checks that iterator.includes() exists, because Iterator helpers are still new. In an older browser it prints a short explanation and the output above. In a current browser it runs the code for real.
How It Works
Iterator holds NaN. One of the values is NaN.
includes finds it. SameValueZero treats NaN as equal to NaN, so the result is true.
Contrast with ===. Plain NaN === NaN is false, which is why this special rule matters.
Example 3 — Start Searching After fromIndex
Skip the first two values, then look for 2 — it will not be found.
JavaScript
const nums = [1, 2, 3, 4, 5].values();
const found = nums.includes(2, 2);
console.log("Has 2 after skip: " + found);
The Try It page first checks that iterator.includes() exists, because Iterator helpers are still new. In an older browser it prints a short explanation and the output above. In a current browser it runs the code for real.
How It Works
fromIndex is 2. The first two values (1 and 2) are skipped.
Search the rest. The remaining values are 3, 4, and 5.
No match. 2 was already skipped, so includes() returns false.
Compatibility
Browser & Runtime Support
Iterator.prototype.includes() is a newer Iterator helper. It is available in recent Chromium and Firefox builds; Safari support is still catching up. Feature-detect before you rely on it.
✓ Newer · Recent engines
iterator.includes()
Supported in Chrome 153+, Edge 153+, Firefox 154+, Safari 27.3+, Opera 137+ and Node.js 24+. Internet Explorer never got it.
RecentStandard since
Google Chrome153+ · Desktop & Mobile
Full support
Microsoft Edge153+ · Chromium based
Full support
Mozilla Firefox154+ · Desktop & Mobile
Full support
Apple Safari27.3+ · macOS & iOS
Partial / recent
Opera137+ · Chromium based
Full support
Samsung InternetRecent · Android
Supported
Android WebView153+ · Chromium based
Supported
Node.js24+ · Server runtime
Supported
DenoRecent versions · JavaScript runtime
Supported
BunRecent versions · JavaScript runtime
Supported
Internet ExplorerNo native support
Not supported
iterator.includes()Recent engines
Bottom line: Feature-detect with typeof Iterator.prototype.includes === "function" (or join). On older engines, convert with Array.from() and use the matching Array method.
Frequently Asked Questions
It returns true if the iterator yields a value equal to the one you pass in, using SameValueZero. Otherwise it returns false. The iterator is consumed.
Yes. SameValueZero treats NaN as equal to NaN, so includes(NaN) can return true. That is different from ===, where NaN === NaN is false.
No. Unlike Array.prototype.includes(), a negative fromIndex is not allowed on iterators, because there is no known length from the end.
No. includes() closes the iterator whether or not a match was found. Make a new iterator if you need another search.
It is a newer helper. Feature-detect with typeof Iterator.prototype.includes !== "function" before you rely on it in older browsers.