Array.prototype.find()
find(callbackFn, thisArg) Returns:
T | undefined · Added in vES6 · Updated March 13, 2026 · Array Methods array find iteration search
The find() method returns the first element in an array that satisfies the provided testing function. If no element matches, it returns undefined. Unlike filter() which always returns an array, find() returns the actual element or nothing.
Syntax
find(callbackFn, thisArg)
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
callbackFn | function | required | Function to test each element |
thisArg | object | undefined | Value to use as this when executing callbackFn |
callbackFn Parameters
| Parameter | Type | Description |
|---|---|---|
element | any | Current element being processed |
index | number | Index of current element |
array | Array | Array that find was called on |
Examples
Finding a number
const numbers = [5, 12, 8, 130, 44];
const found = numbers.find(num => num > 10);
console.log(found);
// 12
Finding an object in an array
const users = [
{ name: 'Alice', age: 28 },
{ name: 'Bob', age: 34 },
{ name: 'Charlie', age: 22 }
];
const youngUser = users.find(user => user.age < 25);
console.log(youngUser);
// { name: 'Charlie', age: 22 }
Using index parameter
const items = ['apple', 'banana', 'cherry', 'date'];
const found = items.find((item, index) => index > 1 && item.startsWith('c'));
console.log(found);
// 'cherry'
When no match is found
const numbers = [1, 2, 3, 4, 5];
const result = numbers.find(num => num > 100);
console.log(result);
// undefined
Common Patterns
Finding by property
const products = [
{ id: 1, name: 'Laptop', price: 999 },
{ id: 2, name: 'Phone', price: 699 },
{ id: 3, name: 'Tablet', price: 449 }
];
const product = products.find(p => p.name === 'Phone');
// { id: 2, name: 'Phone', price: 699 }
First matching vs filter
const numbers = [1, 2, 3, 4, 5];
// find returns the element
console.log(numbers.find(n => n > 3));
// 4
// filter returns a new array
console.log(numbers.filter(n => n > 3));
// [4, 5]
See Also
- array::filter — returns all matching elements
- array::findIndex — returns the index instead
- array::some — tests if any element passes