主题
dropRight
js
_.dropRight(array, [n=1])创建 array 的一个切片,其中从结尾删除了 n 个元素。
¥Creates a slice of array with n elements dropped from the end.
新增于
¥Since
3.0.0
参数
¥Arguments
array(数组):要查询的数组。¥
array(Array): The array to query.[n=1](数值):要删除的元素数。¥
[n=1](number): The number of elements to drop.
返回
¥Returns
(数组):返回 array 的切片。
¥(Array): Returns the slice of array.
示例
¥Example
js
_.dropRight([1, 2, 3]);
// => [1, 2]
_.dropRight([1, 2, 3], 2);
// => [1]
_.dropRight([1, 2, 3], 5);
// => []
_.dropRight([1, 2, 3], 0);
// => [1, 2, 3]