主题
pullAllBy
js
_.pullAllBy(array, values, [iteratee=_.identity])
此方法与 _.pullAll
类似,不同之处在于它接受 iteratee
,调用 array
和 values
中的每个元素生成比较标准。迭代器使用一个参数调用:(value)。
¥This method is like _.pullAll
except that it accepts iteratee
which is invoked for each element of array
and values
to generate the criterion by which they're compared. The iteratee is invoked with one argument: (value).
注意:与 _.differenceBy
不同,此方法会改变 array
。
¥Note: Unlike _.differenceBy
, this method mutates array
.
新增于
¥Since
4.0.0
参数
¥Arguments
array
(数组):要修改的数组。¥
array
(Array): The array to modify.values
(数组):要删除的值。¥
values
(Array): The values to remove.[iteratee=_.identity]
(函数):每个元素调用迭代器。¥
[iteratee=_.identity]
(Function): The iteratee invoked per element.
返回
¥Returns
(数组):返回 array
。
¥(Array): Returns array
.
示例
¥Example
js
var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }];
_.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x');
console.log(array);
// => [{ 'x': 2 }]