Get to know MDN better
This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2015.
The find() method of Array instances returns the first element in the provided array that satisfies the provided testing function. If no values satisfy the testing function, undefined is returned.
A function to execute for each element in the array. It should return a truthy value to indicate a matching element has been found, and a falsy value otherwise. The function is called with the following arguments:
elementThe current element being processed in the array.
indexThe index of the current element being processed in the array.
arrayThe array find() was called upon.
thisArg OptionalA value to use as this when executing callbackFn. See iterative methods.
The first element in the array that satisfies the provided testing function. Otherwise, undefined is returned.
The find() method is an iterative method. It calls a provided callbackFn function once for each element in an array in ascending-index order, until callbackFn returns a truthy value. find() then returns that element and stops iterating through the array. If callbackFn never returns a truthy value, find() returns undefined. Read the iterative methods section for more information about how these methods work in general.
callbackFn is invoked for every index of the array, not just those with assigned values. Empty slots in sparse arrays behave the same as undefined.
The find() method is generic. It only expects the this value to have a length property and integer-keyed properties.
The following example returns the first element in the array that is a prime number, or undefined if there is no prime number.
Note: The isPrime() implementation is for demonstration only. For a real-world application, you would want to use a heavily memoized algorithm such as the Sieve of Eratosthenes to avoid repeated calculations.
The array argument is useful if you want to access another element in the array, especially when you don't have an existing variable that refers to the array. The following example first uses filter() to extract the positive values and then uses find() to find the first element that is less than its neighbors.
Empty slots in sparse arrays are visited, and are treated the same as undefined.
The find() method reads the length property of this and then accesses each property whose key is a nonnegative integer less than length.
| ECMAScript® 2027 Language Specification # sec-array.prototype.find |
Enable JavaScript to view this browser compatibility table.
This page was last modified on Jul 20, 2025 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.