map: Iterate an array elements and modify the array elements. It takes a callback function with elements, index , array parameter and return a new array.

PHOTO EMBED

Fri Sep 16 2022 16:32:10 GMT+0000 (Coordinated Universal Time)

Saved by @sreejithbs

const modifiedArray = arr.map(function (element, index, arr) {
  return element
})

/*Arrow function and explicit return
const modifiedArray = arr.map((element,index) => element);
*/

//Example
const numbers = [1, 2, 3, 4, 5]
const numbersSquare = numbers.map((num) => num * num)
content_copyCOPY

https://github.com/Asabeneh/30-Days-Of-JavaScript/blob/master/09_Day_Higher_order_functions/09_day_higher_order_functions.md