主题
pullAt
js
_.pullAt(array, [indexes])
从 array
中删除与 indexes
对应的元素并返回已删除元素的数组。
¥Removes elements from array
corresponding to indexes
and returns an array of removed elements.
注意:与 _.at
不同,此方法会改变 array
。
¥Note: Unlike _.at
, this method mutates array
.
新增于
¥Since
3.0.0
参数
¥Arguments
array
(数组):要修改的数组。¥
array
(Array): The array to modify.[indexes]
(...(数值|数值[])):要删除的元素的索引。¥
[indexes]
(...(number|number[])): The indexes of elements to remove.
返回
¥Returns
(数组):返回已删除元素的新数组。
¥(Array): Returns the new array of removed elements.
示例
¥Example
js
var array = ['a', 'b', 'c', 'd'];
var pulled = _.pullAt(array, [1, 3]);
console.log(array);
// => ['a', 'c']
console.log(pulled);
// => ['b', 'd']