tail.js 457 B

12345678910111213141516171819202122
  1. var baseSlice = require('./_baseSlice');
  2. /**
  3. * Gets all but the first element of `array`.
  4. *
  5. * @static
  6. * @memberOf _
  7. * @since 4.0.0
  8. * @category Array
  9. * @param {Array} array The array to query.
  10. * @returns {Array} Returns the slice of `array`.
  11. * @example
  12. *
  13. * _.tail([1, 2, 3]);
  14. * // => [2, 3]
  15. */
  16. function tail(array) {
  17. var length = array == null ? 0 : array.length;
  18. return length ? baseSlice(array, 1, length) : [];
  19. }
  20. module.exports = tail;