I'm trying to find whether lodash has a function where I can filter based on some query, return an array of the matched objects, but remove the matched objects from the original array.
So very similar to _.filter, but where the original array is modified with the matched elements removed.
Example
var originalArray = [1, 2, 3, 4, 5];
console.log(originalArray);
----> 1, 2, 3, 4, 5
var evenNumbers = _.somethingSimilarToFilter(originalArray, function(n) {
return n % 2 === 0
});
console.log(evenNumbers);
----> 2, 4
console.log(originalArray);
----> 1, 3, 5