O'Reilly logo

Learning Underscore.js by Alex Pop

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Aggregations and transformations

We dealt so far with functions tasked with extracting a value or a range of values from collections, and we will now move to functions that aggregate or transform collections. Aggregate functions operate over an entire collection to extract or calculate a single value or a limited set of values. Transformation functions operate over an entire collection and return a new collection that is usually a different representation of the original collection.

The first example of an aggregate function was _.reduce() and the first example of a transformation function was _.map(). The former calculates an accumulator value from the entire collection and the latter creates a new collection from the original collection.

Aggregations ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required