JavaScript Higher Order Functions
Let's Talk about Map Baby
In my article Things I Wish We Learned In Bootcamp, I listed programming fundamentals as my number 4, if I was ordering them in a sequence of importance, that very well could have been number 1. In this article and the next 3 that follow, I will be discussing higher-order array functions. In this article, we will be discussing map, how to use it, why to use it and when to use it. I will include a ton of really powerful resources that I implore you to check out.
Map: The What
A map method is used to create a new array with the results of calling a function iterated over every element in an array. A few things to note here:
- Map does not perform a function for an empty element
- Map does not mutate the original array
array.map(//some operation)
Let's look at the map function in use:
Here we see a simple map function, it iterates over an array of numbers and then multiples every number by five then returns a new array…