UNPKG

js-fns

Version:

Modern JavaScript utility library focused on the build size

19 lines (17 loc) 513 B
/** * Returns the index of the last matching element in an array. * * @param array - The array to find element index in * @param matcher - The function that returns true if element satisfies a condition * @returns A last element index that satisfies the condition * * @category Array * @public */ export default function findLastIndex(array, matcher) { for (var index = array.length - 1; index >= 0; index--) { var _element = array[index] if (matcher(_element)) return index } return -1 }