array.each()

call the given UDF/Closure with every value in the array.

array.each( closure [, parallel [, maxThreads ] ] )

Returns: void

Argument Description
closure
function, required

UDF/Closure that call with the values from array

Alias: function, callback, udf

parallel
boolean, optional

execute closures parallel

maxThreads
number, optional

maximum number of threads executed, ignored when argument "parallel" is set to false

Examples

Basic Example
aNames = array("Marcus", "Sarah", "Josefine");
aNames.each(
    function(element) {
        dump(element);
    }
);
Parallel Example with 3 Threads
start = getTickCount();
a = ["a","b","c","d","e","f","g","h","i"];
a.each(function(element, index, array) {
    writeOutput("<code>#index#:#element# [#getTickCount()#]</code><br/>");
    sleep(100);
}, true, 3);
writeOutput('Total Time: #(getTickCount()-start)# milliseconds<br/>');

See also