const fruits = ['apple', 'banana', 'orange', 'banana', 'grape'];
// Search backwards for 'banana' from index 3
const lastBananaFrom3 = Arr.lastIndexOfFrom(fruits, 'banana', 3);
// Search backwards for 'banana' from index 2
const lastBananaFrom2 = Arr.lastIndexOfFrom(fruits, 'banana', 2);
// Element not found
const notFound = Arr.lastIndexOfFrom(fruits, 'grape', 2);
// Curried version
const findBananaFrom3 = Arr.lastIndexOfFrom('banana', 3);
const index = findBananaFrom3(fruits);
console.log(lastBananaFrom3); // => 3
console.log(lastBananaFrom2); // => 1
console.log(notFound); // => -1
console.log(index); // => 3
Gets the last index of a value in an array, starting from a specified index.
const fruits = ['apple', 'banana', 'orange', 'banana', 'grape'];
// Search backwards for 'banana' from index 3
const lastBananaFrom3 = Arr.lastIndexOfFrom(fruits, 'banana', 3);
// Search backwards for 'banana' from index 2
const lastBananaFrom2 = Arr.lastIndexOfFrom(fruits, 'banana', 2);
// Element not found
const notFound = Arr.lastIndexOfFrom(fruits, 'grape', 2);
// Curried version
const findBananaFrom3 = Arr.lastIndexOfFrom('banana', 3);
const index = findBananaFrom3(fruits);
console.log(lastBananaFrom3); // => 3
console.log(lastBananaFrom2); // => 1
console.log(notFound); // => -1
console.log(index); // => 3
Gets the last index of a value in an array, starting from a specified index.