findLastBy (source code)
- Curried: true
- Failsafe status: alternative available
The findLastBy
function finds the last item in the array that matches the
provided pattern.
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.
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 }