| var baseIteratee = require('./_baseIteratee'), |
| basePullAt = require('./_basePullAt'); |
| * 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. |
| * @param {Array} array The array to modify. |
| * @param {Function} [predicate=_.identity] The function invoked per iteration. |
| * @returns {Array} Returns the new array of removed elements. |
| * var array = [1, 2, 3, 4]; |
| * var evens = _.remove(array, function(n) { |
| function remove(array, predicate) { |
| if (!(array && array.length)) { |
| predicate = baseIteratee(predicate, 3); |
| while (++index < length) { |
| var value = array[index]; |
| if (predicate(value, index, array)) { |
| basePullAt(array, indexes); |