2022-01-21 08:28:41 +00:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
var numberIsNaN = require("../../number/is-nan")
|
|
|
|
, toPosInt = require("../../number/to-pos-integer")
|
|
|
|
, value = require("../../object/valid-value")
|
|
|
|
, lastIndexOf = Array.prototype.lastIndexOf
|
|
|
|
, objHasOwnProperty = Object.prototype.hasOwnProperty
|
|
|
|
, abs = Math.abs
|
|
|
|
, floor = Math.floor;
|
|
|
|
|
2022-03-14 15:40:45 +00:00
|
|
|
module.exports = function (searchElement /*, fromIndex*/) {
|
2022-01-21 08:28:41 +00:00
|
|
|
var i, fromIndex, val;
|
|
|
|
if (!numberIsNaN(searchElement)) {
|
|
|
|
// Jslint: ignore
|
|
|
|
return lastIndexOf.apply(this, arguments);
|
|
|
|
}
|
|
|
|
|
|
|
|
value(this);
|
|
|
|
fromIndex = arguments[1];
|
|
|
|
if (isNaN(fromIndex)) fromIndex = toPosInt(this.length) - 1;
|
|
|
|
else if (fromIndex >= 0) fromIndex = floor(fromIndex);
|
|
|
|
else fromIndex = toPosInt(this.length) - floor(abs(fromIndex));
|
|
|
|
|
|
|
|
for (i = fromIndex; i >= 0; --i) {
|
|
|
|
if (objHasOwnProperty.call(this, i)) {
|
|
|
|
val = this[i];
|
|
|
|
if (numberIsNaN(val)) return i; // Jslint: ignore
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
};
|