VDL Plugin SDK

without

Import from @varavel/vdl-plugin-sdk/utils/arrays.

function without<T>(array, ...values): T[];

Creates an array that excludes all specified values.

It correctly excludes NaN, as it compares values using SameValueZero.

Type Parameters

Type ParameterDescription
TThe type of elements in the array.

Parameters

ParameterTypeDescription
arrayreadonly T[]The array to filter.
...valuesT[]The values to exclude.

Returns

T[]

A new array without the specified values.

Examples

// Removes the specified values from the array
without([1, 2, 3, 4, 5], 2, 4);
// Returns: [1, 3, 5]
// Removes specified string values from the array
without(['a', 'b', 'c', 'a'], 'a');
// Returns: ['b', 'c']