26: Transforming Data

Functional Programming in JavaScript is limited mostly to using "data transforms" and callbacks. As you learned in Exercise 25 you can't really do recursion, but you can use functions to change data easily. What you can do reliably is transform data using four functions:

  • map -- Apply a calculation on each element.
  • reduce -- Turn a sequence into a final calculation.
  • find -- Search for an element in a sequence.
  • filter -- Filter out selected elements from a sequence.
  • forEach -- Just loop over a sequence without a result.

I'm using the word "sequence" since these functions should be on most anything that works like an Array ...maybe...if they did it right. Let's look at each one:


Learn JavaScript Today

Register today for the Beginner Basics course and get the new releases by just paying the difference. There's also special discounts for existing customers when new courses are released.

Still Not Sure? Check out more curriculum!