The function iterates over items in a set and returns a new list based on the results of a given callback function.
Be aware that the order when iterating over a set or a thing is not guaranteed.
This function does not generate a change.
set.map(callback)
Explanation of the callback argument:
Iterable | Arguments | Description |
---|---|---|
set | thing, Id | Iterate over things in the set. Both thing and id are optional. |
A new list of items that are the result of the callback function.
This code shows an example using map():
users = [{name: "Iris", age: 6}, {name: "Sasha", age: 34}];
// returns ["Iris", "Sasha"]
set(users).map(|user| user.name).sort();
Return value in JSON format
[
"Iris",
"Sasha"
]