Lodash _.dropRight

2021-09-22 09:30 更新

_.dropRight(array, [n=1])

创建一个切片数组,去除array尾部的n个元素。(n默认值为1。)

引入版本

3.0.0

参数

  1. array (Array): 要查询的数组。
  2. [n=1] (number): 要去除的元素个数。

返回值

(Array): 返回array剩余切片。

例子

_.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]


以上内容是否对您有帮助:
在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号