Skip to content

Latest commit

 

History

History
31 lines (22 loc) · 831 Bytes

findLastBy.md

File metadata and controls

31 lines (22 loc) · 831 Bytes

findLastBy (source code)

  • Curried: true
  • Failsafe status: alternative available

The findLastBy function finds the last item in the array that matches the provided pattern.

Arguments:

  • pattern: The pattern using which an object will be matched.
  • entityArray: The array of objects in which the object with the given pattern will be searched.

Usage:

const array = [
  { name: "Oliver", age: 20 },
  { name: "Sam", age: 40 },
  { name: "George", age: 41 },
  { name: "Smith", age: 20 },
];

findLastBy({ age: 20 }, array); // { name: "Smith", age: 20 }
findLastBy({ name: includes("e") }, array); // { name: "George", age: 41 }

See also