Underscore.js Collection Methods

Beginner
6 min read
Updated: Nov 2026
25 method guides
Method index

About This Index

This page is the Underscore.js Collections index for the tutorial track. Each row links to a full guide with syntax, examples, and FAQs.

Learn the Underscore overview on /underscore-js. Use this page when you need a collection API such as _.each(), _.map(), or _.filter().

Beginner path.

Start with _.each(), then _.map(), _.filter(), and _.reduce()—then browse the rest by category.

How to Call a Collection Method

Pass a list (array or object) as the first argument; iteratees receive (value, indexOrKey, list):

Underscore
const nums = [1, 2, 3, 4];
const people = [
  { name: "moe", age: 40 },
  { name: "larry", age: 50 }
];

_.each(nums, function (n) { console.log(n); });
_.map(nums, function (n) { return n * 2; });     // [2, 4, 6, 8]
_.filter(nums, function (n) { return n % 2 === 0; }); // [2, 4]
_.reduce(nums, function (sum, n) { return sum + n; }, 0); // 10
_.pluck(people, "name");  // ["moe", "larry"]
_.groupBy(people, "age"); // { 40: [...], 50: [...] }

Underscore.js Collection Methods Table

All collection method guides in this Underscore.js tutorial series (25 tutorials).

Getting Started

4 methods

Core iterators — each, map, and left/right reduce.

MethodDescriptionTutorial
_.each()Iterates a list (array or object), calling iteratee for each value (alias: _.forEach).Try it
_.map()Produces a new array by transforming each value (alias: _.collect).Try it
_.reduce()Folds a list into a single value from left to right (alias: _.foldl / _.inject).Try it
_.reduceRight()Right-associative reduce — folds from last element to first (alias: _.foldr).Try it

Test Membership

3 methods

Ask whether all, any, or a specific value is present.

MethodDescriptionTutorial
_.every()Returns true if all values pass the predicate (alias: _.all).Try it
_.some()Returns true if any value passes the predicate (alias: _.any).Try it
_.contains()Returns true if the value is present (alias: _.includes / _.include).Try it

Extract & Aggregate

4 methods

Invoke methods, pluck properties, and find min/max.

MethodDescriptionTutorial
_.invoke()Calls the named method on each value with optional arguments.Try it
_.pluck()Extracts a list of property values — a convenient map shorthand.Try it
_.max()Returns the maximum value, optionally by an iteratee.Try it
_.min()Returns the minimum value, optionally by an iteratee.Try it

Organize

4 methods

Sort, group, index, and count by an iteratee.

MethodDescriptionTutorial
_.sortBy()Returns a sorted copy ranked by iteratee criteria.Try it
_.groupBy()Groups values into an object keyed by the iteratee result.Try it
_.indexBy()Indexes values into an object keyed by the iteratee — one value per key.Try it
_.countBy()Counts values grouped by the iteratee result.Try it

Sample & Convert

5 methods

Shuffle, sample, convert to arrays, measure size, and partition.

MethodDescriptionTutorial
_.shuffle()Returns a shuffled copy using a Fisher–Yates style shuffle.Try it
_.sample()Picks a random element, or n random elements.Try it
_.toArray()Creates a real array from an iterable or array-like object.Try it
_.size()Returns the number of values in the list (array length or object keys).Try it
_.partition()Splits values into two arrays — [pass, fail] — by a predicate.Try it

Frequently Asked Questions

They are Underscore helpers that work on arrays, array-like values, and plain objects—iterating (_.each), transforming (_.map), folding (_.reduce), filtering (_.filter / _.find), grouping (_.groupBy), and sampling (_.shuffle / _.sample).
Collections work on arrays and objects with the same API. Array methods focus on array-only helpers such as _.first, _.uniq, and _.zip. Start here for map/filter/reduce, then open Arrays for end-of-list and uniqueness tools.
Most return new data: _.map, _.filter, _.sortBy, and _.pluck leave the input unchanged. _.each returns the original list for chaining but is meant for side effects.
_.each runs a callback for side effects and returns the original list. _.map collects each iteratee return value into a new array—use it when you need transformed data.
Start with _.each(), then _.map(), _.filter(), and _.reduce() from the table below.

Start with _.each()

Open the iteration guide—syntax, examples, and FAQs.

_.each() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

14 people found this page helpful