Reducing collections

It's now time to look at reducing collections. Lo-Dash helps a lot here too, supplying functions that help us reduce arrays, objects, and anything that's thrown our way. Aside from primitives, all data structures can be reduced to something simpler.

We'll start off by looking at the common reduce cases, summing values, and such. This will be followed by the topic of filtering collections and how it relates to reducing. Then, we'll look at some more advanced computational techniques.

Summing values

Unlike other programming languages, JavaScript has no built-in mechanism to sum together an array of values. The closest we get to summing is the native Array.reduce() method, which is actually general purpose and not specifically for ...

Get Lo-Dash Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.