This video discusses map, a Lodash function used to apply transformations to arrays of data. We show how instead of using a for loop to cycle through an array, we can use map, leading to cleaner, more robust code.
- [Instructor] The first of these functions we'll be…talking about is called map.…Map is used when you want to take all the elements…in an array and convert them to some other value.…For example, if you wanted to double all the elements…in an array or convert an array of inch measurements into…an array of centimeter measurements.…The way we do this is by passing map an array and…some function to apply to each element in the array.…Map then returns another array that contains the return…values of the function for each element.…So in other words, it takes each element and maps it to…the return value of the function we give it.…
If the function we pass is something like square,…for example, map returns an array where each of the…numbers has been squared.…And of course, you can pass in an anonymous function…to make it do essentially whatever you want.…There is one important thing to remember with the…map function and the rest of these functions.…In typical functional fashion, they don't actually change…the array we pass it.…
- What's functional programming?
- Functional vs. object-oriented programming
- First-class functions
- Higher-order functions
- Array functions
- Mapping, filtering, and reducing
- Simple callbacks
- Callbacks with arguments