Pular para o conteúdo principal

ArrayFilter

Takes an array of objects and filters them based on a given condition, returning a new array containing only the elements that match. The original array is not modified.

Reference

Parameters

array

The array of items to filter.

Component data2-core-types@Getter

filter

The condition each item must satisfy to be included in the result.

Component data2-core-functions@Function

Example

Input

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

Condition: car_color == "yellow"

Output:

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

Note: Only the elements that satisfy the condition are included in the output. Elements that do not match are excluded but not deleted from the original array. If no elements match the condition, an empty array is returned.