2
0

last-index.js 374 B

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