Returns the last element of an array. Passing n will return the last n elements of the array
返回一个数组中的最后一个元素
_.last([5, 4, 3, 2, 1]);
=> 1
源码:
_.last = function(array, n, guard) {
if ((n != null) && !guard) {
return slice.call(array, Math.max(array.length - n, 0));
} else {
return array[array.length - 1];
}
};
浙公网安备 33010602011771号