UNPKG

517 BJavaScriptView Raw
1var makeIterator = require('../function/makeIterator_');
2
3 /**
4 * Returns the index of the last item that matches criteria
5 */
6 function findLastIndex(arr, iterator, thisObj){
7 iterator = makeIterator(iterator, thisObj);
8 if (arr == null) {
9 return -1;
10 }
11
12 var n = arr.length;
13 while (--n >= 0) {
14 if (iterator(arr[n], n, arr)) {
15 return n;
16 }
17 }
18
19 return -1;
20 }
21
22 module.exports = findLastIndex;
23
24