---
schema_version: "1"
id: 12ab3e9320f21f10a879cea297f92ef779e1570b998d0b61f0c2fc0dceb65871
title: indexWhere
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/2.6/dw-arrays-functions-indexwhere.md
canonical_url: https://docs.mulesoft.com/dataweave/2.6/dw-arrays-functions-indexwhere
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 2e44161c37780dfc7d0c1d382c8d8875c11ecec0d5fc3fe315978cda1330019f
description: MuleSoft Documentation Site
release: "2.6"
latest: false
---
---
product: DataWeave
version: 2.6
---

# indexWhere

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

## indexWhere<T>(array: Array<T>, condition: (item: T) -> Boolean): Number

Returns the index of the first occurrence of an element that matches a condition within the array.
If no element matches the condition, the function returns `-1`.

_Introduced in DataWeave version 2.2.0._

### Parameters

<table><colgroup><col> <col></colgroup><thead><tr><th>Name</th><th>Description</th></tr></thead><tbody><tr><td><p><code>array</code></p></td><td><p>The array of elements.</p></td></tr><tr><td><p><code>condition</code></p></td><td><p>The condition (or expression) used to match an element in the array.</p></td></tr></tbody></table>

### Example

This example returns the index of the value from the input array that matches the condition in the
lambda expression, `(item) → item startsWith "Jul"`.

#### Source

```DataWeave
%dw 2.0
import * from dw::core::Arrays
output application/json
var users = ["Mariano", "Leandro", "Julian"]
---
users indexWhere (item) -> item startsWith "Jul"
```

#### Output

```json
2
```

## indexWhere(array: Null, condition: (item: Nothing) -> Any): Null

Helper function that enables `indexWhere` to work with a `null` value.

_Introduced in DataWeave version 2.4.0._
