🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
## lastIndexOf + [link](./lastIndexOf "Link to this entry.") + [source](https://github.com/lodash/lodash/blob/4.5.0正式版/lodash.src.js#L6218 "View in source.") + [npm](https://www.npmjs.com/package/lodash.lastindexof "See the npm package.") ``` _.lastIndexOf(array, value, [fromIndex=array.length-1]) ``` 这个方法类似 `_.indexOf`,除了它是从右到左遍历元素的。 这个方法类似 `_.indexOf` except that it iterates over elements of `array` from right to left. ### 参数 1. array (Array) 需要检索的数组 2. value (\*) 要检索的值 3. [fromIndex=array.length-1] (number) 检索 index 的起点 ### 返回值 (number) 返回匹配元素的 index,否则返回 -1 ### 示例 ``` _.lastIndexOf([1, 2, 1, 2], 2); // => 3 // 使用了 `fromIndex` _.lastIndexOf([1, 2, 1, 2], 2, 2); // => 1 ```