主题
pullAllWith
js
_.pullAllWith(array, values, [comparator])
此方法与 _.pullAll
类似,不同之处在于它接受 comparator
,调用该方法可比较 array
和 values
的元素。比较器使用两个参数调用:(arrVal, othVal)。
¥This method is like _.pullAll
except that it accepts comparator
which is invoked to compare elements of array
to values
. The comparator is invoked with two arguments: (arrVal, othVal).
注意:与 _.differenceWith
不同,此方法会改变 array
。
¥Note: Unlike _.differenceWith
, this method mutates array
.
新增于
¥Since
4.6.0
参数
¥Arguments
array
(数组):要修改的数组。¥
array
(Array): The array to modify.values
(数组):要删除的值。¥
values
(Array): The values to remove.[comparator]
(函数):每个元素调用的比较器。¥
[comparator]
(Function): The comparator invoked per element.
返回
¥Returns
(数组):返回 array
。
¥(Array): Returns array
.
示例
¥Example
js
var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }];
_.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual);
console.log(array);
// => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }]