pull and pullAll remove every occurrence of the given values from an array by mutating it in place, and return that same array — not a copy. They are the mutating counterparts of set-difference helpers like difference: instead of building a new array of what is left, they reach into the array you passed and delete the matches, so any variable still holding that array sees the change. This is lodash's _.pull and _.pullAll.
Implement both, packaged on one object named `{ pull, pullAll }`. pull is variadic (the values come as extra arguments); pullAll takes the values as a single array. pull should delegate to pullAll.
pullValues = { pull, pullAll }
// remove every value from `array` IN PLACE, then return that same array:
pull(array, ...values) // values as extra args: pull(arr, 2, 3)
pullAll(array, values) // values as one array: pullAll(arr, [2, 3])
pull([1, 2, 3, 1, 2, 3], 2, 3);
// → [1, 1] the return value IS the same array, now mutated
pullAll([1, 2, 3, 1, 2, 3], [2, 3]);
// → [1, 1] pullAll takes the values as one array
pull([2, 2, 2, 1], 2); // → [1] every copy gone, even adjacent ones
pull([NaN, 1, NaN], NaN); // → [1] NaN matches NaN
pull([1, 2, 3], 9); // → [1, 2, 3] nothing to remove: unchanged
pull(a, x) === a is true. Do not allocate or return a new array.Array.prototype.includes and Set use, where NaN matches NaN and -0 matches 0. (Plain indexOf and === would miss NaN.)pull(a) and pullAll(a, []) return a unchanged, still the same reference._.pull — build the behavior yourself; the point is the in-place removal, not the library call.