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

# isNotNil es-toolkit

Checks if a value is neither `null` nor `undefined`.

```typescript
const result = isNotNil(value);
```

## Usage

### `isNotNil(value)`

Use `isNotNil` when you want to check if a value is neither `null` nor `undefined`. It's particularly useful for filtering out `null` or `undefined` values from arrays.

```typescript
import { isNotNil } from 'es-toolkit/predicate';

// Basic usage
console.log(isNotNil(42)); // true
console.log(isNotNil('hello')); // true
console.log(isNotNil([])); // true
console.log(isNotNil({})); // true

console.log(isNotNil(null)); // false
console.log(isNotNil(undefined)); // false

// Useful for array filtering
const mixedArray = [1, null, 'hello', undefined, true, 0];
const filteredArray = mixedArray.filter(isNotNil);
// filteredArray becomes [1, 'hello', true, 0] (null and undefined removed)
```

It can also be used as a type guard in TypeScript.

```typescript
function processItems(items: (string | null | undefined)[]) {
  // Filtering with isNotNil narrows the type to string[]
  const validItems = items.filter(isNotNil);

  validItems.forEach(item => {
    // item is now guaranteed to be of type string
    console.log(item.toUpperCase());
  });
}
```

#### Parameters


valueT | null | undefinedrequired

The value to check if it's neither `null` nor `undefined`.

#### Returns

Returns `true` if the value is neither `null` nor `undefined`, `false` otherwise.

```typescript
value is T
```


Source: es-toolkit

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