Skip to main content

forEach()

iterates over all items of a data collection

forEach(callback: DataCallback<T>): void;

Parameters:

callback: function - a function that will iterate over items of a data collection

Example

component.data.forEach(function(element, index, array) {    console.log("This is an item of dataCollection: ", element);    console.log("This is an index of the element: ", index);    console.log("This is an array of the elements: ", array);});

Related sample: Data. ForEach

The callback function takes three parameters:

element(object) the object of an item
index(number) the index of an item
array(array) an array with items

Change log:

added in v6.4