Skip to content

Latest commit

 

History

History
31 lines (22 loc) · 818 Bytes

findLastIndexBy.md

File metadata and controls

31 lines (22 loc) · 818 Bytes

findLastIndexBy (source code)

  • Curried: true
  • Failsafe status: alternative available

The findLastIndexBy function finds the last index of an 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 },
];

findLastIndexBy({ age: 20 }, array); // returns 3
findLastIndexBy({ name: includes("e") }, array); // returns 2

See also