first-index.js 407 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 = 0;
  9. while (!objHasOwnProperty.call(this, i)) {
  10. if (++i === length) return null;
  11. }
  12. return i;
  13. };