多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
## findLastIndex + [link](./findLastIndex "Link to this entry.") + [source](https://github.com/lodash/lodash/blob/4.5.0正式版/lodash.src.js#L5912 "View in source.") + [npm](https://www.npmjs.com/package/lodash.findlastindex "See the npm package.") ``` _.findLastIndex(array, [predicate=_.identity]) ``` 这个方式类似 `_.findIndex` , 不过它是从右到左的。 ### 参数 1. array (Array) 需要搜索的数组 2. [predicate=_.identity] (Function|Object|string) 这个函数会在每一次迭代调用 ### 返回值 (number) 返回符合元素的 index,否则返回 `-1`。 ### 示例 ``` var users = [ { 'user': 'barney', 'active': true }, { 'user': 'fred', 'active': false }, { 'user': 'pebbles', 'active': false } ]; _.findLastIndex(users, function(o) { return o.user == 'pebbles'; }); // => 2 // 使用了 `_.matches` 的回调结果 _.findLastIndex(users, { 'user': 'barney', 'active': true }); // => 0 // 使用了 `_.matchesProperty` 的回调结果 _.findLastIndex(users, ['active', false]); // => 2 // 使用了 `_.property` 的回调结果 _.findLastIndex(users, 'active'); // => 0 ```