up.util.map(list, block)
JavaScript function
Maps all items in a list to a new array of items.
Example
The given mapping function will be called for each element in the list:
up.util.map(['apple', 'cherry'], (str) => str.length) // result: [5, 6]
You can also pass a property name as a string, which will be collected from each item in the list:
up.util.map(['apple', 'cherry'], 'length') // result: [5, 6]
Parameters
list
required
Type: List | Iterator
block
required
A function that will be called with each element and (optional) iteration index.
You can also pass a property name as a string, which will be collected from each item in the list.
Type: Function(element, index): any | string
Return value
A new array containing the result of each function call.
Type: Array