mdn .map() code example

Example 1: js map constructor

let myMap = new Map([
  [1, 'one'], // [key, value]
  [2, 'two'],
  [3, 'three'],
]) // from MDN

Example 2: array mdn map

let new_array = arr.map(function callback( currentValue[, index[, array]]) {
    // return element for new_array
}[, thisArg])

Example 3: javascript map

array.map( item => item.id )

array2.map( item => item.toString() )

array2.map( item => item * 3 )

// this will apply a transformation to all elements of an array
// "" item => something "" is the transformation (function)