mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-11 11:27:50 +00:00
Simplify tail.
This commit is contained in:
8
tail.js
8
tail.js
@@ -1,5 +1,3 @@
|
|||||||
import baseSlice from './.internal/baseSlice.js'
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets all but the first element of `array`.
|
* Gets all but the first element of `array`.
|
||||||
*
|
*
|
||||||
@@ -14,7 +12,11 @@ import baseSlice from './.internal/baseSlice.js'
|
|||||||
*/
|
*/
|
||||||
function tail(array) {
|
function tail(array) {
|
||||||
const length = array == null ? 0 : array.length
|
const length = array == null ? 0 : array.length
|
||||||
return length ? baseSlice(array, 1, length) : []
|
if (!length) {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
const [head, ...result] = array
|
||||||
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
export default tail
|
export default tail
|
||||||
|
|||||||
Reference in New Issue
Block a user