12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- var baseFindIndex = require('./_baseFindIndex'),
- baseIsNaN = require('./_baseIsNaN'),
- strictLastIndexOf = require('./_strictLastIndexOf'),
- toInteger = require('./toInteger');
- var nativeMax = Math.max,
- nativeMin = Math.min;
- function lastIndexOf(array, value, fromIndex) {
- var length = array == null ? 0 : array.length;
- if (!length) {
- return -1;
- }
- var index = length;
- if (fromIndex !== undefined) {
- index = toInteger(fromIndex);
- index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1);
- }
- return value === value
- ? strictLastIndexOf(array, value, index)
- : baseFindIndex(array, baseIsNaN, index, true);
- }
- module.exports = lastIndexOf;
|