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

# noop es-toolkit

An empty function that does nothing.

```typescript
noop();
```

::: info [`asyncNoop`](https://massaman.dev/reference/function/asyncNoop.md) function

If you need a function that asynchronously does nothing, use the `asyncNoop` function which immediately returns a `Promise<void>`.

:::

## Usage

### `noop()`

Use `noop` when you need a function that performs no operation.

This is useful as a default value where a function is required or when you want to disable a callback function. It's frequently used as a placeholder or during initialization.

```typescript
import { noop } from 'es-toolkit/function';

// Using as a default value for optional callbacks
interface EventHandlers {
  onSuccess?: () => void;
  onError?: () => void;
}

function processData({ onSuccess = noop, onError = noop }: EventHandlers = {}) {
  try {
    // Data processing logic
    console.log('Data processing complete');
    onSuccess(); // Safe to call
  } catch (error) {
    onError(); // Safe to call
  }
}

// Safe to use without undefined checks
processData({
  onSuccess: () => console.log('Success!'),
  // onError is handled as noop by default
});
```

It can also be used with array methods.

```typescript
import { noop } from 'es-toolkit/function';

// Conditionally execute functions
const operations = [
  () => console.log('First task'),
  shouldRunSecond ? () => console.log('Second task') : noop,
  () => console.log('Third task'),
];

operations.forEach(op => op()); // Execute all operations safely
```

#### Returns

Returns nothing.

```typescript
void
```


Source: es-toolkit

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