map
Modified on Fri, 18 Aug 2023
Description
Return a new array from calling an expression for every array element.
Syntax
map(array, element, expression)
Parameters
Input Parameter | Type | Description |
---|---|---|
array | Array | The array map() was called upon |
element | any | The current element being processed in the array |
expression | expression | An expression to be run for each array element. |
Return value
Type |
---|
Array<any> |
Sample
Example | Result | Description |
---|---|---|
map([4, 8], x, x*10) | [40, 80] | Returns the new mapped array |
map([{'name' : 'John', 'age' : 18},{'name' : 'Raj', 'age' : 25}], x, toUpper(x.name)) | [{'name' : 'JOHN', 'age' : 18},{'name' : 'RAJ', 'age' : 25}] | Change all user names to upper case |
map(a, x, arraySum(filter(x, y, y>10))) | [ 20, 110 ] | Apply map with filter function |
To view all the List functions, click here.
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article