iterator.find(callback) walks each value until your function says "yes, this one". Then it returns that value. If no value passes the test, the result is undefined.
The method consumes the iterator. When a match is found, remaining values are not read, and the iterator is closed. You cannot continue from the same iterator afterward.
Remember
iterator.find(callback)
first match → that value
no match → undefined
stops early → yes, on the first match
Consumes the iterator (it is closed after the call).
Callback gets (value, index).
Syntax
Call it on an iterator and pass a function that returns true for the value you want.
Required. A function called for each value until a match is found. Return a truthy value to select that item, or a falsy value to keep looking. It receives value and index (starting at 0).
Return Value
Return Value
Description
value or undefined
The first value for which the callback returned a truthy result. If nothing matched (or the iterator was empty), the result is undefined. The iterator is closed either way.
JavaScript Examples
Example 1 — Find the First Matching Value
Get the first number greater than 3 from an iterator.
The Try It page first checks that iterator.find() 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 in order.
Test each value. 1, 2, and 3 fail the test n > 3.
Return the match. 4 passes, so find() returns 4 and stops. 5 is never read.
Example 2 — See What Happens When Nothing Matches
Search for a value that is not there, and get undefined.
The Try It page first checks that iterator.find() 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
Search the whole iterator. Every number is 5 or less, so none pass n > 100.
No match. When the iterator ends without a hit, find() returns undefined.
Check the type.typeof huge is "undefined", which is the usual "not found" result.
Example 3 — Use Value and Index Together
Find the first value that equals ten times its index (starting at 1 for display).
JavaScript
const nums = [10, 20, 30, 40].values();
const match = nums.find((n, i) => n === (i + 1) * 10);
console.log("Match: " + match);
The Try It page first checks that iterator.find() 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
Callback gets two args.n is the value and i is the zero-based index.
First value wins. At index 0, 10 === 1 * 10 is true, so 10 is returned.
Later values skipped. 20, 30, and 40 are never tested once a match is found.
Compatibility
Browser & Runtime Support
Iterator.prototype.find() is an Iterator helper (Baseline Newly available since March 2025). It works in current browsers and in Node.js 22 or newer.
✓ Baseline 2025 · Newly available
iterator.find()
Supported in Chrome 122+, Edge 122+, Firefox 131+, Safari 18.4+, Opera 108+ and Node.js 22+. Internet Explorer never got it.
2025Standard since
Google Chrome122+ · Desktop & Mobile
Full support
Microsoft Edge122+ · Chromium based
Full support
Mozilla Firefox131+ · Desktop & Mobile
Full support
Apple Safari18.4+ · macOS & iOS
Full support
Opera108+ · Chromium based
Full support
Samsung Internet26+ · Android
Supported
Android WebView122+ · Chromium based
Supported
Node.js22+ · Server runtime
Supported
DenoRecent versions · JavaScript runtime
Supported
BunRecent versions · JavaScript runtime
Supported
Internet ExplorerNo native support
Not supported
iterator.find()Current browsers
Bottom line: Check support with a typeof test before you use it in older browsers. Prefer chaining helpers and calling toArray() last.
Frequently Asked Questions
It returns the first value from an iterator that passes your test function. If nothing matches, it returns undefined. The iterator is consumed.
It returns the value. The index is only passed into your callback as the second argument if you need it while testing.
find() returns undefined. That is different from find() never finishing on an infinite iterator when the callback never returns a truthy value.
No. find() closes the iterator, even when it stops early on a match. Call .values() again (or make a new iterator) if you need another pass.
The idea matches Array.prototype.find(), but it works on an iterator. Feature-detect Iterator helpers in older browsers before you rely on them.