cf2:ForEach

Purpose

Provides support for iterating over the properties of objects and the indexes of arrays.

Exported Features

cf2:ForEach

Imported Features

n/a

JavaScript

This component adds the following methods to the Object.prototype object.

v_forEach(function)

Iterates over the properties in the object invoking the function for each property in turn. The order in which the properties are iterated is undefined.

Parameter Description Type
function The iteration function. Function
function(p)

Invoked for each item in the object. When invoked, the this property is set to the object being iterated over and so the value of the item can be accessed as this[i].

Parameter Description Type
p The property of the item in the object that is currently being visited during the iteration. String

This component adds the following methods to the Array.prototype object.

v_forEach(function)

Iterates over the indexes in the array invoking the function for each index in turn. It iterates over the indexes in order from '0' to 'length - 1'.

Parameter Description Type
function The iteration function. Function
function(i)

Invoked for each item in the array. When invoked, the this property is set to the array being iterated over and so the value of the item can be accessed as this[i].

Parameter Description Type
i The index of the item in the array that is currently being visited during the iteration. Integer

Related topics