_.without(array, ...values) returns a new array with every occurrence of the given values removed. It's the "subtract these items" operation — strip a few IDs out of a list, drop the selected tags, filter out sentinel values — without touching the original.
Implement without(arr, ...values). Return a copy of arr that excludes any element equal to one of values, compared with SameValueZero (so a NaN in the exclusion list removes NaN elements). Order is preserved and the input is never mutated.
function without(arr, ...values) {
// returns a new array containing arr's elements that are NOT in `values`,
// matched by SameValueZero.
}
without([1, 2, 3, 4], 2, 4); // [1, 3]
without([1, 2, 1, 3, 1], 1); // [2, 3] — every 1 removed
without([1, NaN, 2], NaN); // [1, 2] — NaN is matched and removed
without([1, 2, 3]); // [1, 2, 3] — nothing to remove, full copy
===, but NaN matches NaN. So NaN in values removes NaN elements.arr.