---
schema_version: "1"
id: d1ca67f7b75f841caf5376f912d80b01dddb03b39c428be68bf64e1c9720de98
title: indexOf
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/latest/dw-arrays-functions-indexof.md
canonical_url: https://docs.mulesoft.com/dataweave/latest/dw-arrays-functions-indexof
source_site: docs.mulesoft.com
content_type: documentation
content_hash: a689d088f4cc587bc354fdc60f898e04f3dbc92c1d523e740d23a7a98c06ccf8
description: MuleSoft Documentation Site
release: "2.13"
latest: true
---
---
product: DataWeave
version: 2.13
is-latest-version: true
---

# indexOf

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

## indexOf<T>(array: Array<T>, toFind: T): Number

Returns the index of the first occurrence of an element within the array. If the value is not found,
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>toFind</code></p></td><td><p>The element to find.</p></td></tr></tbody></table>

### Example

This example returns the index of the matching value from the input array. The index of `"Julian"`
is `2`.

#### Source

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

#### Output

```json
2
```
