Lodash Collection Methods

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().
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):
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 methodsCore iterators — forEach, map, and left/right reduce.
| Method | Description | Tutorial |
|---|---|---|
_.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 |
Search & Filter
5 methodsFind matches, keep or reject values, and partition results.
| Method | Description | Tutorial |
|---|---|---|
_.find() | First element matching predicate; undefined when none match. | Try it |
_.findLast() | Last element matching predicate, scanning from the end. | Try it |
_.filter() | Elements matching predicate; same spirit as Array.prototype.filter. | Try it |
_.reject() | Opposite of filter—elements where predicate is falsy. | Try it |
_.partition() | Split into [matches, rejects] by predicate. | Try it |
Test Membership
3 methodsAsk whether all, any, or a specific value is present.
Transform & Flat Map
4 methodsMap into nested results and flatten, or invoke methods per item.
| Method | Description | Tutorial |
|---|---|---|
_.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 methodsCount, group, key, and sort by iteratee criteria.
| Method | Description | Tutorial |
|---|---|---|
_.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 methodsShuffle, sample, and measure collection size.
| Method | Description | Tutorial |
|---|---|---|
_.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
Start with _.forEach()
Open the iteration guide—syntax, examples, and FAQs.
14 people found this page helpful
