mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-09 02:17:50 +00:00
cleaning up _.last implementation.
This commit is contained in:
@@ -335,7 +335,11 @@
|
|||||||
// Get the last element of an array. Passing **n** will return the last N
|
// Get the last element of an array. Passing **n** will return the last N
|
||||||
// values in the array. The **guard** check allows it to work with `_.map`.
|
// values in the array. The **guard** check allows it to work with `_.map`.
|
||||||
_.last = function(array, n, guard) {
|
_.last = function(array, n, guard) {
|
||||||
return (n != null) && !guard ? slice.call(array, Math.max(array.length - n, 0)) : array[array.length - 1];
|
if ((n != null) && !guard) {
|
||||||
|
return slice.call(array, Math.max(array.length - n, 0));
|
||||||
|
} else {
|
||||||
|
return array[array.length - 1];
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Returns everything but the first entry of the array. Aliased as `tail`.
|
// Returns everything but the first entry of the array. Aliased as `tail`.
|
||||||
|
|||||||
Reference in New Issue
Block a user