Polyfill of map function
map is a method present in the prototype object of Array i.e., Array.prototype. It is used to modify the array elements. It basically accepts one callback function as an argument which in turn accepts 2 parameters as an arguments i.e., current item and index.
Before proceeding to polyfill, first lets see the basic working example of map.

In the above example, we need the resultant list to contain the elements where at each index value should be index multiplied by current value.
Polyfill

In the above polyfill example, First we need to create a method (customMap) in the array prototype which takes function as an argument. Now the next step is iterate over each element and pass it to the callback function (fn). It will return the modified value based on the logic implemented in the function and store it in the temporary array list (tempArr). The temporary array list would contain final array list which need to be return.
Hope this article would help you.
Please follow me here on Medium and consider sharing with your friends!