forEach()
iterates over all items of a data collection
forEach(callback: (item: object, index?: number, array?: object[]) => any): void;
Parameters:
callback: function
- a function that will iterate over items of a data collection. The function takes three parameters:item
- (required) the object of an itemindex
- (optional) the index of an itemarray
- (optional) an array with items
Example
component.data.forEach(function(item, index, array) {
console.log("This is an item of dataCollection: ", item);
console.log("This is an index of the element: ", index);
console.log("This is an array of the elements: ", array);
});
Related sample: Data. ForEach
Change log:
added in v6.4