Lodash Util Methods

About This Index
This page is the Lodash Util index for the tutorial track. Each row links to a full guide with syntax, examples, and FAQs.
Learn strings and collections on /lodash/string and /lodash/collection. Use this page for glue helpers such as _.identity(), _.flow(), or _.times().
Start with _.identity(), then _.flow(), _.times(), and _.uniqueId()—then browse iteratee and stub helpers.
How to Call a Util Method
Call utilities on _ like any other Lodash helper:
import _ from "lodash";
_.identity(5); // 5
_.constant("ok")(); // "ok"
_.defaultTo(null, 42); // 42
const double = function (n) { return n * 2; };
const square = function (n) { return n * n; };
_.flow([double, square])(3); // 36
_.times(3, function (i) { return i * 2; }); // [0, 2, 4]
_.range(1, 5); // [1, 2, 3, 4]
_.uniqueId("user_"); // "user_1"
_.attempt(function () { return JSON.parse("{bad"); });
// returns a SyntaxError instead of throwing Lodash Util Methods Table
All util method guides in this Lodash tutorial series (34 tutorials).
Getting Started
5 methodsIdentity defaults, constants, no-ops, defaults, and safe attempts.
| Method | Description | Tutorial |
|---|---|---|
_.identity() | Return the first argument unchanged—the default iteratee in many Lodash APIs. | Try it |
_.constant() | Return a function that always yields the same value. | Try it |
_.noop() | Empty function that does nothing—placeholder callback or default iteratee. | Try it |
_.defaultTo() | Return a default value only when the input is null or undefined. | Try it |
_.attempt() | Invoke a function in try/catch; return the result or the caught error object. | Try it |
Compose & Cond
6 methodsWire functions together with flow, cond, and over helpers.
| Method | Description | Tutorial |
|---|---|---|
_.flow() | Compose functions left to right; each step receives the previous return value. | Try it |
_.flowRight() | Compose functions right to left (mathematical compose). | Try it |
_.cond() | Build a conditional function from ordered [predicate, handler] pairs. | Try it |
_.over() | Map the same input through multiple functions; return an array of results. | Try it |
_.overEvery() | AND-combine predicates: true only when every predicate passes. | Try it |
_.overSome() | OR-combine predicates: true when at least one predicate passes. | Try it |
Iteratee & Match
9 methodsBuild callbacks, matchers, property getters, and method invokers.
| Method | Description | Tutorial |
|---|---|---|
_.iteratee() | Convert property shorthands, matchers, and objects into a callback function. | Try it |
_.matches() | Deep partial-match predicate: does the value contain the spec shape? | Try it |
_.matchesProperty() | Predicate that checks whether a value at path equals an expected value. | Try it |
_.conforms() | Return a predicate that checks whether an object matches a shape of predicates. | Try it |
_.property() | Return a getter function for a path (shorthand for partial _.get). | Try it |
_.propertyOf() | Like property, but the object is fixed when the getter is created. | Try it |
_.method() | Return a function that invokes a named method on the first argument object. | Try it |
_.methodOf() | Like method, but the object is the second argument to the returned function. | Try it |
_.nthArg() | Return a function that picks the nth argument from the outer call. | Try it |
Generate
5 methodsRepeat work, build ranges, mint ids, and parse paths.
| Method | Description | Tutorial |
|---|---|---|
_.times() | Invoke an iteratee n times with indices 0…n−1; collect return values. | Try it |
_.range() | Build a numeric array from start/end/step (end exclusive). | Try it |
_.rangeRight() | Like range but produces values from right to left. | Try it |
_.uniqueId() | Generate an incrementing string id with an optional prefix. | Try it |
_.toPath() | Convert a dot/bracket path string into an array of key segments. | Try it |
Stubs
5 methodsAlways-empty or always-boolean placeholder factories.
| Method | Description | Tutorial |
|---|---|---|
_.stubArray() | Return a function that always yields a new empty array. | Try it |
_.stubObject() | Return a function that always yields a new empty object. | Try it |
_.stubString() | Return a function that always yields an empty string. | Try it |
_.stubTrue() | Return a function that always yields true. | Try it |
_.stubFalse() | Return a function that always yields false. | Try it |
Extend Lodash
4 methodsMixin custom methods, reclaim _, bind methods, and isolate context.
| Method | Description | Tutorial |
|---|---|---|
_.mixin() | Add custom functions onto Lodash (extend Lodash itself). | Try it |
_.noConflict() | Restore the previous global _ variable and return the Lodash instance. | Try it |
_.bindAll() | Bind own method names on an object so this stays fixed for callbacks. | Try it |
_.runInContext() | Create an isolated Lodash instance with a fresh internal state. | Try it |
Frequently Asked Questions
Start with _.identity()
Open the identity guide—syntax, examples, and FAQs.
12 people found this page helpful
