.remove(array, [predicate=.identity])
Removes all elements from array
that predicate
returns truthy for and returns an array of the removed elements. The predicate is invoked with three arguments: (value, index, array).Note: Unlike _.filter
, this method mutates array
. Use _.pull
to pull elements from an array by value.
Since
2.0.0
Arguments
array
(Array): The array to modify.[predicate=.identity]
(Function)_: The function invoked per iteration.
Returns
(Array): Returns the new array of removed elements.
Example
var array = [1, 2, 3, 4];var evens = _.remove(array, function(n) {return n % 2 == 0;});console.log(array);// => [1, 3]console.log(evens);// => [2, 4]
当前内容版权归 lodash.com 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 lodash.com .