without
Returns a new array with all occurrences of the given values removed.
Unlike difference, which operates on two arrays as set operands, without
uses a variadic API suited for removing known sentinel values inline.
Uses SameValueZero equality (same as Array.prototype.includes).
null and undefined are treated as empty arrays and return [].
Available since v2.0.0
Import
Section titled “Import”Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
array | readonly T[] | null | undefined | The source array. |
values | T[] | One or more values to exclude from the result. |
Returns
Section titled “Returns”T[] — A new array without the specified values.
Examples
Section titled “Examples”Remove a single value
Section titled “Remove a single value”Returns a new array with all occurrences of the given value removed.
Remove multiple values
Section titled “Remove multiple values”All listed values are excluded from the result.
