> For the complete documentation index, see [llms.txt](https://lodash.shujuwajue.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lodash.shujuwajue.com/array/findlastindex.md).

# \_.findLastIndex（查找元素的索引值）

**语法：**

```javascript
_.findLastIndex(array, [predicate=_.identity], [fromIndex=array.length-1])
```

**源代码链接：**[source](https://github.com/lodash/lodash/blob/4.17.10/lodash.js#L7296)

**npm包链接：**[npm package](https://www.npmjs.com/package/lodash.findlastindex)

**描述：**

这个方法类似于[`_.findIndex`](https://lodash.com/docs/4.17.10#findIndex)。除了它从右到左遍历集合的元素。

**开始版本：**&#x32;.0.0

**参数：**

* `array (Array)`: 需要检索的数组。
* `[predicate=_.identity] (Function)`: 每个迭代函数调用。
* `[fromIndex=array.length-1] (number)`: 开始搜索的索引值。

**返回值：**

* `(number)`: 返回查找到的元素索引值，否则ｆ返回 `-1`。

**例子：**

```javascript
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
```

注意：不同的方式代表：`_.matches`，`_.matchesProperty`，`_.property`的简写法
