mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 06:27:49 +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`.
|
||||
*
|
||||
@@ -14,7 +12,11 @@ import baseSlice from './.internal/baseSlice.js'
|
||||
*/
|
||||
function tail(array) {
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user