4.17.11
3.10.1
2.4.2
1.3.1
_.findLastIndex(array, [predicate=_.identity], [fromIndex=array.length-1])
This method is like _.findIndex
except that it iterates over elements
of collection
from right to left.
Since
2.0.0
Arguments
argument
array
[predicate=_.identity]
[fromIndex=array.length-1]
type
Array
Function
number
description
The array to inspect.
The function invoked per iteration.
The index to search from.
Returns
(array)
Example
var users = [
{ user: "barney", active: true },
{ user: "fred", active: false },
{ user: "pebbles", active: false },
];
_.findLastIndex(users, function (o) {
return o.user == "pebbles";
});
// => 2
// The `_.matches` iteratee shorthand.
_.findLastIndex(users, {
user: "barney",
active: true,
});
// => 0
// The `_.matchesProperty` iteratee shorthand.
_.findLastIndex(users, [
"active",
false,
]);
// => 2
// The `_.property` iteratee shorthand.
_.findLastIndex(users, "active");
// => 0
var users = [
{ user: "barney", active: true },
{ user: "fred", active: false },
{ user: "pebbles", active: false },
];
_.findLastIndex(users, function (o) {
return o.user == "pebbles";
});
// => 2
// The `_.matches` iteratee shorthand.
_.findLastIndex(users, { user: "barney", active: true });
// => 0
// The `_.matchesProperty` iteratee shorthand.
_.findLastIndex(users, ["active", false]);
// => 2
// The `_.property` iteratee shorthand.
_.findLastIndex(users, "active");
// => 0