last-index.js 412 B

123456789101112131415
  1. "use strict";
  2. var toPosInt = require("../../number/to-pos-integer")
  3. , value = require("../../object/valid-value")
  4. , objHasOwnProperty = Object.prototype.hasOwnProperty;
  5. module.exports = function () {
  6. var i, length;
  7. if (!(length = toPosInt(value(this).length))) return null;
  8. i = length - 1;
  9. while (!objHasOwnProperty.call(this, i)) {
  10. if (--i === -1) return null;
  11. }
  12. return i;
  13. };