For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt, and this page is available as Markdown at /reference/array/without.md.

without es-toolkit

Creates a new array excluding specific values from the array.

const filtered = without(arr, ...values);

Usage

without(arr, ...values)

Use without when you want to remove unwanted specific values from an array. The original array is not modified, and a new array with the specified values removed is returned.

import { without } from 'es-toolkit/array';

// Remove specific values from a number array.
without([1, 2, 3, 4, 5], 2, 4);
// Returns: [1, 3, 5]

// Remove specific value from a string array.
without(['a', 'b', 'c', 'a'], 'a');
// Returns: ['b', 'c']

It also handles NaN values correctly.

import { without } from 'es-toolkit/array';

without([1, NaN, 3, NaN, 5], NaN);
// Returns: [1, 3, 5]

Parameters

arrreadonly T[]required

The array from which to remove values.

...valuesArray<T>required

The values to remove from the array.

Returns

Returns a new array with the specified values removed.

T[]
Source: es-toolkit

Re-exported verbatim from es-toolkit. Implementation, edge cases, and performance behavior are owned upstream. This page mirrors the documentation at the pinned version; the linked source is authoritative.