JavaScript Higher Order Functions & Arrays

Here, we have a fantastic video from Brad Traversy going over forEach, map, filter, reduce and sort. He provides a lot of examples of use for each of these higher order function and, in many cases, compares the code against a for loop and then using standard JavaScript notation vs arrow functions from ES6. Enjoy!

Here are the timestamps, from the comments:

  • ForEach() – 3:25 – 5:30
  • Filter() – 5:30 – 15:30 (8:55 One liner filter code) (filter returns an array – meaning you do not need a separate variable for an array)
  • Map() – 15:45 – 21:05 (20:30 You can link multiple Map() like .then() from promises)
  • Sort() – 21:10 – 25:50 (Takes two parameters)
  • Reduce() – 25:50 – 30:55 (Reduces the array to a single value – from LEFT to RIGHT)
  • Extra : 31:05 – 33:40 (Combine all four methods)

Map() was much more powerful that I’d been giving it credit for. I generally haven’t manipulated and then refined data multiple times with it, like was done in this video. It gives me a lot of food for thought.

Here are two other videos I shared that also go over JavaScript array methods:

Leave a comment