# wrIsDefined

> Type guard that drops `null` and `undefined`, for use with `Array.filter`.

Source: https://ngwr.dev/reference/utils/wr-is-defined  
Kind: Util  
Updated in v16  
Optional

## Usage

```angular-ts
import { wrIsDefined } from 'ngwr/utils';

const items: (string | null | undefined)[] = ['a', null, 'b', undefined];
const present = items.filter(wrIsDefined); // string[]
```

## API

| Name | Description | Type | Default |
| --- | --- | --- | --- |
| `wrIsDefined(v)` | Narrows out `null` and `undefined`. Pass it straight to `Array.filter`. | `<T>(v: T \| null \| undefined) => v is T` | `—` |

## See also

- [wrIsNonEmptyArray](https://ngwr.dev/reference/utils/wr-is-non-empty-array) — Type guard for an array with at least one element, so [0] is typed T.
- [Common types](https://ngwr.dev/reference/interfaces/common) — Shared type aliases from ngwr/utils.
- [wrIsObservable](https://ngwr.dev/reference/utils/wr-is-observable) — Checks at runtime whether a value is an RxJS Observable.
