# \_.lastIndexOf(array, value, fromIndex=array.length-1 )

URL: https://caijiao.org/lodash/docs/Array/_.lastIndexOf
Source: docs/lodash/docs/Array/_.lastIndexOf.md
Description: _.lastIndexOf(array, value, [fromIndex=array.length-1])用于获取数组中指定值的最后一个索引位置。

`_.lastIndexOf(array, value, [fromIndex=array.length-1])` 是 [Lodash](/lodash/) 库中的一个函数，用于获取数组中指定值的最后一个索引位置。

- **解释：** 这个函数接受一个数组、一个值以及一个可选的起始索引位置作为参数。它从指定的起始索引位置开始向前搜索数组，返回指定值在数组中的最后一个匹配项的索引，如果没有找到匹配项，则返回 -1。

- **应用举例：**

```javascript
const array = [1, 2, 3, 4, 2, 3];
const lastIndex = _.lastIndexOf(array, 2);
console.log(lastIndex); // 输出: 4
```

在这个例子中，`array` 是一个包含数字的数组。通过调用 `_.lastIndexOf(array, 2)`，获取到了值为 `2` 的最后一个索引位置，即索引 `4`。
