Lodash Collection Methods

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

About This Index

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

Learn array reshaping on /lodash/array. Use this page when you need iteration APIs such as _.map(), _.filter(), or _.groupBy().

Beginner path.

Start with _.forEach(), then _.map(), _.filter(), and _.reduce()—then browse grouping and sorting helpers.

How to Call a Collection Method

Pass an array or plain object; iteratees receive (value, indexOrKey, collection):

Lodash
import _ from "lodash";

const nums = [1, 2, 3, 4];
const people = [
  { name: "fred", age: 40 },
  { name: "barney", age: 36 }
];

_.forEach(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
_.groupBy(people, "age");  // { 40: [...], 36: [...] }
_.sortBy(people, "age");   // barney, then fred

Lodash Collection Methods Table

All collection method guides in this Lodash tutorial series (26 tutorials).

Getting Started

5 methods

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

MethodDescriptionTutorial
_.forEach()Invoke iteratee for each entry; returns the collection for chaining (alias: _.each).Try it
_.forEachRight()Like forEach but walks elements from right to left (alias: _.eachRight).Try it
_.map()Transform each element; works on arrays and plain objects.Try it
_.reduce()Fold the collection left-to-right with an accumulator.Try it
_.reduceRight()Fold the collection right-to-left with an accumulator.Try it

Test Membership

3 methods

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

MethodDescriptionTutorial
_.every()Return true if predicate holds for every element (short-circuits).Try it
_.some()Return true if predicate holds for any element (short-circuits).Try it
_.includes()Whether value appears in the collection (SameValueZero for arrays).Try it

Transform & Flat Map

4 methods

Map into nested results and flatten, or invoke methods per item.

MethodDescriptionTutorial
_.flatMap()Map then flatten one level—handy for one-to-many projections.Try it
_.flatMapDeep()Map then recursively flatten until only non-arrays remain.Try it
_.flatMapDepth()Map then flatten up to a chosen depth.Try it
_.invokeMap()Invoke a path/method name on each element, collecting results.Try it

Organize

5 methods

Count, group, key, and sort by iteratee criteria.

MethodDescriptionTutorial
_.countBy()Create an object keyed by iteratee results with counts per group.Try it
_.groupBy()Bucket values into arrays keyed by iteratee output.Try it
_.keyBy()Build an object keyed by iteratee result; last write wins on collisions.Try it
_.orderBy()Sort by one or more iteratees and orders (asc/desc).Try it
_.sortBy()Stable sort by iteratee results (ties preserve prior order).Try it

Sample & Size

4 methods

Shuffle, sample, and measure collection size.

MethodDescriptionTutorial
_.sample()Single random element from the collection.Try it
_.sampleSize()n distinct random elements (without replacement when possible).Try it
_.shuffle()New array with elements in random order.Try it
_.size()Length for arrays/strings; count enumerable own keys on plain objects.Try it

Frequently Asked Questions

They iterate arrays, array-like values, and plain objects: transforming (_.map), filtering (_.filter / _.find), folding (_.reduce), grouping (_.groupBy / _.countBy), sorting (_.sortBy / _.orderBy), and sampling (_.shuffle / _.sample).
Array focuses on reshaping lists (_.chunk, _.zip, _.pull). Collection focuses on iterating—map, filter, reduce—and grouping or ordering outcomes. Collections also work on plain objects.
Helpers like _.map, _.filter, _.sortBy, and _.groupBy return new data. _.forEach does not mutate by itself—your callback might.
Prefer per-method imports: import map from 'lodash/map' or import { map } from 'lodash-es'. You can also use const _ = require('lodash') and call _.map().
Start with _.forEach(), then _.map(), _.filter(), and _.reduce() from the table below.

Start with _.forEach()

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

_.forEach() 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