Skip to main content

.map()

A function that iterates over a given array and executes a specified function on each element, and then returns an array of the results.

Syntax

#fs.scripts.lib().map(array, func);

Parameters

array

The array to iterate over and execute a function on each element.

func

The function to execute on each element.

Return

Returns an array.

Example

function(context, args) {
const l = #fs.scripts.lib();
const my_array = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];

function square(index, value) {
return value * value;
};

return l.map(my_array, square);
}