ArrayReject
Takes an array of objects and excludes all elements that match a given condition, returning a new array containing only the elements that did not match. ArrayReject is the inverse of ArrayFilter: instead of keeping the matching elements, it removes them.
Reference
Parameters
array
The array of items to evaluate.
Component data2-core-types@Getter
filter
The condition; items that satisfy it are excluded from 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": "Bob", "car_color": "blue" }
]
Note: The original array is not modified. If no elements match the condition, the output will be identical to the input array.