> 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.

# intersection (Functional Programming) es-toolkit

Creates a function that keeps values found in another array. Use it with [`pipe`](https://massaman.dev/reference/fp/pipe.md).

```typescript
const result = pipe(array, intersection(secondArray));
```

::: info

Prefer the original es-toolkit [`intersection`](https://massaman.dev/reference/array/intersection.md) in ordinary code. Use this `fp` variant when composing transformations with [`pipe`](https://massaman.dev/reference/fp/pipe.md).

:::

## Usage

`intersection` keeps values from the piped array that are also present in `secondArray`. It preserves the order of the piped array.

```typescript
import { intersection, pipe } from 'es-toolkit/fp';

pipe([1, 2, 3], intersection([2, 3, 4])); // => [2, 3]
```

#### Parameters


secondArrayreadonly T[]required

The array containing values to keep.

#### Returns

A function that maps a `readonly T[]` to values also found in `secondArray`.

```typescript
(array: readonly T[]) => T[]
```


Source: es-toolkit

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