On this page
  1. Array.find
  2. Signature & Overview
  3. Notes & Pitfalls
  4. Example

Array.find

Prev: reduce | Up: Array | Next: flatMap
Rel: Array, Array & Typed Arrays Guide
Ref: MDN Web Docs — Array.find
Tags: #public #web #javascript #builtins #array #tier/core


Signature & Overview

arr.find(predicate)

Returns the first element matching predicate, or undefined (short-circuits on first match).

Notes & Pitfalls

Example

const users = [{ id: 1, name: "Ada" }, { id: 2, name: "Grace" }];
const found = users.find((u) => u.id === 2);
console.assert(found?.name === "Grace");

Linked from

Related notes