JavaScript Array find() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Array

Definition

Array.prototype.find(callback) returns the first element that passes your test. No match → undefined. It stops early and does not mutate the array (ES2015).

Remember
array.find((element, index, array) => test)

first truthy match → that element
no match → undefined
stops at the first hit (does not scan the rest)

filter() → all matches (array)
findIndex() → index of first match (−1 if none)

Syntax

Call array.find. Start with this line.

JavaScript
array.find(callback, thisArg?)
CallWhat it does
array.find(callback, thisArg?)Primary signature.
array.find(...)Call with the arguments your case needs.

Built into JavaScript. Call find(...) on an array instance — no import required.

Library declarations
JavaScript
array.find(callback, thisArg?)

Parameters

ParameterDescription
callbackRequired. Test function; truthy → return that element
index, arrayOptional. Extra callback args when needed

Return Value

Return ValueDescription
*First match, or undefined

JavaScript Examples

Example 1 — First Matching Number

Return the first value greater than 20—later matches are ignored.

JavaScript
const numbers = [10, 25, 5, 40, 15];
const result = numbers.find((n) => n > 20);

console.log(result);  // 25
Try It Yourself

How It Works

  1. Scan from the left. Starts at index 0.
  2. Skip 10. 10 > 20 is false.
  3. Hit 25. First truthy test → return 25 immediately.
  4. 40 is ignored. Even though it also matches, find already stopped.

Example 2 — Handle No Match

When nothing passes, you get undefined—check before using the result.

JavaScript
const numbers = [10, 25, 5, 40, 15];
const result = numbers.find((n) => n > 50);

if (result !== undefined) {
  console.log(result);
} else {
  console.log("No element found.");
}
Try It Yourself

How It Works

  1. Test every element. None are greater than 50.
  2. Return undefined. Not null, not [].
  3. Guard the result. Compare with !== undefined before use.
  4. Show a fallback. Print a clear message when nothing matched.

Example 3 — Find an Object by Property

Locate a user by username—common for lists of records.

JavaScript
const users = [
  { id: 1, username: "john_doe" },

  { id: 2, username: "jane_smith" },

  { id: 3, username: "bob_jones" }
];

const foundUser = users.find((user) => user.username === "jane_smith");

console.log(foundUser);
Try It Yourself

How It Works

  1. Array of objects. Each user has id and username.
  2. Compare a property. Callback checks user.username === "jane_smith".
  3. Return the object. First match is the whole user record.
  4. Same reference. You get the original object from the array—not a copy.

Browser & Runtime Support

Array.prototype.find() is part of ES2015 (ES6). It has been available in evergreen browsers for years and in Node.js since version 4.

✓ Baseline · ES2015

Array.prototype.find()

Supported in Chrome 45+, Firefox 25+, Safari 7.1+, Edge 12+, and Node 4+. Not available in Internet Explorer.

98% Modern browser support
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full support
Array.find() Excellent

Bottom line: Safe for modern web and Node targets. Polyfill only if you must support Internet Explorer.

Frequently Asked Questions

find() returns the first element in an array for which the callback returns a truthy value. If no element matches, it returns undefined.
No. find() only reads elements through your callback. The original array is unchanged.
It returns undefined—not null and not an empty array. Always check for undefined before using the result.
find() stops at the first match and returns that single element. filter() collects every match into a new array.
find() returns the matching element (the value). findIndex() returns the numeric index of the first match, or -1 if none.
find() is an ES2015 (ES6) feature. All modern browsers support it; Internet Explorer does not.

Next: findIndex()

Get the position of the first match—or -1 when nothing passes.

findIndex() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

11 people found this page helpful