Transformations

Now it's time for us to look at transformations that happen to data as it passes through the processing pipelines we construct. What's interesting about Lo-Dash and how it transforms data in chains is that the original collection isn't modified—a new one is constructed. This reduces side effects and is fundamental to the immutability concept in other functional programming languages.

Building groups, unions, and unique values

Some of the most powerful transformation tools found in Lo-Dash can be used out of the box with very little effort. These include grouping collection items by a specific value they contain, joining arrays together while retaining only unique values, and removing any duplicates from arrays. For example:

var collection ...

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.