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

# initial (Functional Programming) es-toolkit

Creates a function that returns all values except the last one. Use it with [`pipe`](https://massaman.dev/reference/fp/pipe.md).

```typescript
const result = pipe(array, initial());
```

::: info

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

:::

## Usage

`initial` returns a new array without the last value of the piped array.

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

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

#### Parameters

This function takes no arguments; call it as `initial()`.

#### Returns

A function that maps a `readonly T[]` to all values except the last one.

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


Source: es-toolkit

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