forEach()
iterates over all items of a tree collection
forEach(callback: function, parentID?: string | number, level?: number): void;
Parameters:
callback: function
- a function that will iterate over items of a tree collection. It takes three parameters:element: object
- the object of an item of a tree collectionindex: number
- the index of an itemarray: object[]
- an array with items
parentID: string | number
- optional, the parent id. If not specified, the function will start iterating over from the root item.level: number
- optional, the number of levels to be iterated over. If not specified, each nested level will be visited.
Example
component.data.forEach(function(element, index, array) {
console.log("This is an item of treeCollection: ", element);
console.log("This is an index of the element: ", index);
console.log("This is an array of the elements: ", array);
});
Change log:
added in v6.4