Skip to main content

mapRange()

returns a new array of the items according to the specified parameters

mapRange(from: number, to: number, callback: (item: object, index?: number, array?: object[]) => any): object[];

Parameters:

  • from: number - the initial position of an item in the range
  • to: number - the final position of an item in the range
  • callback: function - a function that will be called for each item from the specified range. The function is called with the following parameters:
    • item - the object of an item
    • index - the index of an item
    • array - an array of items the method was called upon

Returns:

A new array of matching item objects.

Example

const result = component.data.mapRange(0, 20, function(item, index, array) {
console.log(item.id, index);
});