initial_.initial(array, [n])
Returns everything but the last entry of the array. Especially useful on the arguments object. Pass n to exclude the last n elements from the result.
返回数组的所有元素,最后一个元素除外
_.initial([5, 4, 3, 2, 1]); => [5, 4, 3, 2]
源码:
_.initial = function(array, n, guard) {
return slice.call(array, 0, array.length - ((n == null) || guard ? 1 : n));
};
浙公网安备 33010602011771号