find()

noun

say it: “FYND” /faɪnd/

A JavaScript array method that runs a test on each item and returns the first item that passes, or undefined when none does.

What does find() do in JavaScript?

find() — An Array method that returns the first item satisfying a test.

const orders = [{ id: 1 }, { id: 2 }];
const order = orders.find(item => item.id === 2);

In a sentence

  • “pets.find((pet) => pet.name === 'Pepper') gave me Pepper's whole record.”

Level: Journeyman · More JavaScript terms at this level

Updated