mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 14:37:49 +00:00
23 lines
413 B
JavaScript
23 lines
413 B
JavaScript
/**
|
|
* Gets all but the first element of `array`.
|
|
*
|
|
* @since 4.0.0
|
|
* @category Array
|
|
* @param {Array} array The array to query.
|
|
* @returns {Array} Returns the slice of `array`.
|
|
* @example
|
|
*
|
|
* tail([1, 2, 3])
|
|
* // => [2, 3]
|
|
*/
|
|
function tail(array) {
|
|
const length = array == null ? 0 : array.length
|
|
if (!length) {
|
|
return []
|
|
}
|
|
const [, ...result] = array
|
|
return result
|
|
}
|
|
|
|
export default tail
|