---
title: array.filter() function
description: array.filter() iterates over an array, evaluates each element with a predicate function, and then returns a new array with only elements that match the predicate.
url: https://docs.influxdata.com/flux/v0/stdlib/experimental/array/filter/
estimated_tokens: 369
product: Flux
version: v0
publisher: InfluxData
canonical: https://docs.influxdata.com/flux/v0/stdlib/experimental/array/filter/
date: '2024-04-08T16:01:02-06:00'
lastmod: '2024-04-08T16:01:02-06:00'
---

* Flux 0.155.0 – 0.173.0

InfluxDB support

> [!Important]
> `array.filter()` is experimental and [subject to change at any time](/flux/v0/stdlib/experimental/#experimental-packages-are-subject-to-change).

`array.filter()` iterates over an array, evaluates each element with a predicate function, and then returns
a new array with only elements that match the predicate.

#### Deprecated

Experimental `array.filter()` is deprecated in favor of[`array.filter()`](/flux/v0/stdlib/array/filter).

##### Function type signature

```js
(<-arr: [A], fn: (x: A) => bool) => [A]
```

For more information, see [Function type signatures](/flux/v0/function-type-signatures/).

## Parameters

### arr

Array to filter. Default is the piped-forward array (`<-`).

### fn

(Required)
Predicate function to evaluate on each element.
The element is represented by `x` in the predicate function.

## Examples

### Filter array of integers

```js
import "experimental/array"

a = [
    1,
    2,
    3,
    4,
    5,
]
b = a |> array.filter(fn: (x) => x >= 3)

// b returns [3, 4, 5]
// Output the filtered array as a table
array.from(rows: b |> array.map(fn: (x) => ({_value: x})))
```

[](#view-example-output)

View example output

#### Output data

|\_value|
|-------|
|   3   |
|   4   |
|   5   |

#### Related

* [Work with arrays](/flux/v0/data-types/composite/array/)

[array](/flux/v0/tags/array/)[tables](/flux/v0/tags/tables/)
| _value |
| --- |
| _value |
| 3 |
| 4 |
| 5 |
