Array.prototype.map

Array.prototype.map returns a new array containing the results of calling a given function on every element of the calling array.

callbackFn: A function to execute for each element in the array. Its return value is added as a single element in the new array.

Pollyfill for map

  • Passing the index and array to the map callback.
  • Calling the map callback with the correct this if thisArg is specified.
  • Sparse arrays (e.g. [1, 2, , 4]). The empty values should be ignored while traversing the array.
  • The thisArg doesn't do anything if the callback is defined as an arrow function as arrow functions don't have their own bindings to this.

Resources

--

--

I’m a full-time software engineer who loves sharing knowledge to help others become better developers.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Ayesha Malik

I’m a full-time software engineer who loves sharing knowledge to help others become better developers.