find()

ES6+

Returns the first element in the array that satisfies the provided testing function.

Syntax

array.find(callback(element, index, array), thisArg)

Parameters

callback Function

Function to test each element

Return Value

any

The first element that satisfies the condition, or undefined

Examples

JavaScript
const numbers = [5, 12, 8, 130, 44];
const found = numbers.find(x => x > 10);
console.log(found);
Output:
// 12

Related Methods