---
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/array/filter/
estimated_tokens: 1197
product: Flux
version: v0
---

# array.filter() function

-   Flux 0.173.0+
-   View InfluxDB support

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

##### 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 "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 |

[array](/flux/v0/tags/array/) [tables](/flux/v0/tags/tables/)
