> For AI agents: the complete documentation index is available at https://massaman.dev/llms.txt, the full documentation bundle is available at https://massaman.dev/llms-full.txt.

# pull es-toolkit

Removes all specified values from an array.

```typescript
const result = pull(arr, valuesToRemove);
```

## Usage

### `pull(arr, valuesToRemove)`

Use `pull` when you want to remove all occurrences of specific values from an array. This function modifies the original array directly and returns the modified array.

```typescript
import { pull } from 'es-toolkit/array';

// Remove specific values from a number array.
const numbers = [1, 2, 3, 4, 5, 2, 4];
pull(numbers, [2, 4]);
console.log(numbers); // [1, 3, 5]

// Remove specific strings from a string array.
const fruits = ['apple', 'banana', 'cherry', 'banana', 'date'];
pull(fruits, ['banana', 'cherry']);
console.log(fruits); // ['apple', 'date']

// Remove objects with the same reference from an object array.
const obj1 = { id: 1 };
const obj2 = { id: 2 };
const obj3 = { id: 3 };
const objects = [obj1, obj2, obj3, obj1];
pull(objects, [obj1]);
console.log(objects); // [{ id: 2 }, { id: 3 }]
```

If you want to create a new array without modifying the original, use the `difference` function.

```typescript
import { pull } from 'es-toolkit/array';
import { difference } from 'es-toolkit/array';

const original = [1, 2, 3, 4, 5];

// pull modifies the original array.
const arr1 = [...original];
pull(arr1, [2, 4]);
console.log(arr1); // [1, 3, 5]

// difference returns a new array.
const arr2 = difference(original, [2, 4]);
console.log(original); // [1, 2, 3, 4, 5] (unchanged)
console.log(arr2); // [1, 3, 5]
```

#### Parameters


arrT[]required

The array from which to remove values.


valuesToRemovereadonly unknown[]required

An array of values to remove from the array.

#### Returns

The original array with the specified values removed. The original array is modified and returned.

```typescript
T[]
```


Source: es-toolkit

Re-exported verbatim from [`es-toolkit`](https://es-toolkit.dev/reference/array/pull.html). Implementation, edge cases, and performance behavior are owned upstream. This page mirrors the documentation at the pinned version; the linked source is authoritative.
