Pular para o conteúdo principal

ArrayFindIndex

Takes an array of objects and returns the index (position) of the first element that matches a given condition. Unlike ArrayFind, which returns the element itself, ArrayFindIndex returns its numeric position in the array, starting from zero.

Reference

Parameters

array

The array of items to search.

Component data2-core-types@Getter

filter

The condition used to identify the first matching item.

Component data2-core-functions@Function

Example

Input

[
{ "name": "Alice", "car_color": "blue" },
{ "name": "Bob", "car_color": "yellow" },
{ "name": "Carol", "car_color": "yellow" }
]

Condition: car_color == "yellow"

Output:

1