Pular para o conteúdo principal

ArrayFindLastIndex

Takes an array of objects and returns the index (position) of the last element that matches a given condition. Unlike ArrayFindIndex, which returns the position of the first match, ArrayFindLastIndex scans the array and returns the position of the last matching element.

Reference

Parameters

array

The array of items to search.

Component data2-core-types@Getter

filter

The condition used to identify the last matching item.

Component data2-core-primitives@String

Example

Input

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

Condition: car_color == "yellow"

Output:

2