Map

Map is a higher-order function that allows us to map a callback to each element of a collection. It is particularly useful when translating all elements of an array from one set of values to another. Here is a simple code example:

function myJS()
{
let array = [1, 2, 3];

let arrayPlusTwo = array.map(current => current + 2);

// arrayPlusTwo == [3, 4, 5]

}

This technique makes it possible to avoid using structural loops as much as possible when simply modifying the values of an array.