You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/guides/datacollection/working_with_data_items.md
+16-8Lines changed: 16 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -249,9 +249,9 @@ You can iterate through the items of a data collection, the items of a component
249
249
### Iterating through the items of a data collection
250
250
251
251
The [`forEach()`](data_collection/api/datacollection_foreach_method.md) method iterates through all the items of a data collection. It takes as a parameter a callback function that will iterate over items of a data collection and is called with the following parameters:
The [`map()`](data_collection/api/datacollection_map_method.md) method iterates through all the items of the component. As a parameter it takes a callback function that will be called for each item of a component and returns a new array of items where each item is the result of the callback function.
268
+
The [`map()`](data_collection/api/datacollection_map_method.md) method iterates through all the items of the component. As a parameter it takes a callback function that will be called for each item of a component. The function is called with the following parameters:
269
+
- `item` - the object of an item
270
+
- `index` - the index of an item
271
+
- `array` - an array of items the method was called upon
272
+
273
+
and returns a new array of items where each item is the result of the callback function.
269
274
270
275
~~~jsx
271
276
// getting the ids of all the items of the component
272
-
component.data.map(function(item){
273
-
return item;
277
+
component.data.map(function(item, index, array){
278
+
returnitem.id;
274
279
});
275
280
~~~
276
281
@@ -282,12 +287,15 @@ The [`mapRange()`](data_collection/api/datacollection_maprange_method.md) method
282
287
283
288
-`from: number` - the initial position of an item in the range
284
289
-`to: number` - the final position of an item in the range
285
-
-`callback: function` - a function that will be called for each item from the specified range
290
+
-`callback: function` - a function that will be called for each item from the specified range. The function is called with the following parameters:
291
+
-`item` - the object of an item
292
+
-`index` - the index of an item
293
+
-`array` - an array of items the method was called upon
0 commit comments