You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 rivejä
483 B

4 vuotta sitten
  1. var isIndex = require('./_isIndex');
  2. /**
  3. * The base implementation of `_.nth` which doesn't coerce arguments.
  4. *
  5. * @private
  6. * @param {Array} array The array to query.
  7. * @param {number} n The index of the element to return.
  8. * @returns {*} Returns the nth element of `array`.
  9. */
  10. function baseNth(array, n) {
  11. var length = array.length;
  12. if (!length) {
  13. return;
  14. }
  15. n += n < 0 ? length : 0;
  16. return isIndex(n, length) ? array[n] : undefined;
  17. }
  18. module.exports = baseNth;