JavaScript Iterator find()
Example
Find the value of the first element with a value over 18:
const myIterator = Iterator.from([3, 10, 18, 20]);
// Find first element greater than 18
let result = myIterator.find(x => x > 18);
Description
The find() method returns the value of the first element that passes a test.
The find() method executes a function for each array element.
The find() method returns undefined if no elements are found.
The find() method does not execute the function for empty elements.
The find() method does not change the original iterator.
Syntax
Parameters
A function to run for each iterator element.
The value of the current element.
The index of the current element.
The array of the current element.
undefined.A value passed to the function as its
this value.
Return Value
Otherwise it returns
undefined.
Browser Support
iterator.find() is a JavaScript 2025 feature.
ES 2025 is supported in all modern browsers since May 2025:
| Chrome 136 |
Edge 136 |
Firefox 129 |
Safari 18.2 |
Opera 120 |
| Apr 2025 | Apr 2025 | Aug 2024 | Des 2024 | May 2025 |