Description:-

This is used to filter the elements of an array. this will return an array after filtering.

arrayFilter( array, function( item [,index, array] ){ } [, parallel] [, maxThreadCount] )

Attributes:-

array:- This is a required argument, the name of the array object.

filter/callback:- This is a required argument, The inline function is executed for each element in the array. Returns true if the array element has to be included in the resultant array. The callback function accepts these Callback parameters:-
value:- any: The value for the current iteration.
index (optional):- numeric: The current index for the iteration.
array (optional):- array: A reference of the original array.

parallel:- This is a non-required attribute, the default value is false, set as true if the items can be executed in parallel.

maxThreads:- This is a non-required attribute, the default value is 20.

Example:-

fruitArray = [
    {
        'fruit' = 'apple',
        'rating' = 4
    },
    {
        'fruit' = 'banana',
        'rating' = 1
    },
    {
        'fruit' = 'orange',
        'rating' = 5
    },
    {
        'fruit' = 'mango',
        'rating' = 2
    },
    {
        'fruit' = 'kiwi',
        'rating' = 3
    }
];

favoriteFruits = arrayFilter( fruitArray, function( item ){
    return item.rating >= 3;
} );

writedump( serializeJSON( favoriteFruits ) );

Result:-

[
    {
        "fruit": "apple",
        "rating": 4
    },
    {
        "fruit": "orange",
        "rating": 5
    },
    {
        "fruit": "kiwi",
        "rating": 3
    }
]

An example by using a member function:-

fruitArray = [
    {
        'fruit' = 'apple',
        'rating' = 4
    },
    {
        'fruit' = 'banana',
        'rating' = 1
    },
    {
        'fruit' = 'orange',
        'rating' = 5
    },
    {
        'fruit' = 'mango',
        'rating' = 2
    },
    {
        'fruit' = 'kiwi',
        'rating' = 3
    }
];

favoriteFruits = fruitArray.filter( function( item ){
    return item.rating >= 3;
} );

writedump( serializeJSON( favoriteFruits ) );

Result:-

[
    {
        "fruit": "apple",
        "rating": 4
    },
    {
        "fruit": "orange",
        "rating": 5
    },
    {
        "fruit": "kiwi",
        "rating": 3
    }
]