Copy as Markdown View as Markdown (opens in new tab) View on GitHub (opens in new tab) Open in... ChatGPT (opens in new tab) Claude (opens in new tab) Perplexity (opens in new tab) indexOf 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 Name Description array The array of elements. toFind The element to find. Example This example returns the index of the matching value from the input array. The index of "Julian" is 2. Source %dw 2.0 import * from dw::core::Arrays output application/json var users = ["Mariano", "Leandro", "Julian"] --- indexOf(users, "Julian") Output 2