About Pi Downloads Documentation Plugins Developer Forum Issues

Array.forEach

Summary

Executes a provided function once per array element.(It's just created on old browsers which haven't got this method natively)

Syntax

Array.forEach(function)

Example

>>> var list = [3,5,7,9]
>>> list.forEach(function(_value,_index,_array){
        trace('value: ',_value,' index:',_index,' array:',_array);
})
"Value: " 3 "Index :" 0 "Array :" [3,5,7,9]
"Value: " 5 "Index :" 1 "Array :" [3,5,7,9]
"Value: " 7 "Index :" 2 "Array :" [3,5,7,9]
"Value: " 9 "Index :" 3 "Array :" [3,5,7,9]

See Also