Lodash _.iteratee() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Util

Definition

Creates a callback from a shorthand value: a property name, a matcher object, a path/value pair, or a function. Part of Lodash Util since 4.0.0 (stable — not deprecated).

Note: Collection methods already call this internally. Use _.iteratee when you need an explicit, reusable function.

Syntax

Call _.iteratee. Start with this line.

Lodash
_.iteratee([func=_.identity])
CallWhat it does
_.iteratee([func=_.identity])Primary signature.
_.iteratee(...)Call the util helper.

Prefer import iteratee from "lodash/iteratee" when you want a smaller bundle.

Library declarations
Lodash
_.iteratee([func=_.identity])

Parameters

ParameterDescription
funcOptional. Value to convert; default _.identity

Return Value

Return ValueDescription
*A callback function

Lodash Examples

Example 1 — Official: Property Getter

A string becomes a property accessor for each element.

Lodash
var users = [
  { 'user': 'barney', 'age': 36, 'active': true },
  { 'user': 'fred',   'age': 40, 'active': false }
];

_.map(users, _.iteratee('user'));
// → ['barney', 'fred']
Try It Yourself

How It Works

  1. Shorthand. 'user' means “read the user field.”
  2. Factory. _.iteratee('user') returns a getter function.
  3. Map. Each object’s user value is collected.
  4. Result. ['barney', 'fred'] — same idea as _.property('user').

Example 2 — Official: Matches Object

A plain object becomes a partial-match predicate.

Lodash
var users = [
  { 'user': 'barney', 'age': 36, 'active': true },
  { 'user': 'fred',   'age': 40, 'active': false }
];

_.filter(users, _.iteratee({ 'user': 'barney', 'active': true }));
// → [{ 'user': 'barney', 'age': 36, 'active': true }]
Try It Yourself

How It Works

  1. Matcher. The object lists required key/value pairs.
  2. Predicate. _.iteratee({…}) acts like _.matches.
  3. Filter. Only barney matches both user and active.
  4. Extra keys. age on the element is ignored — partial match.

Example 3 — Official: Path / Value Pair

An array [path, value] checks one path against a value.

Lodash
var users = [
  { 'user': 'barney', 'age': 36, 'active': true },
  { 'user': 'fred',   'age': 40, 'active': false }
];

_.filter(users, _.iteratee(['user', 'fred']));
// → [{ 'user': 'fred', 'age': 40, 'active': false }]
Try It Yourself

How It Works

  1. Pair. ['user', 'fred'] means path user must equal 'fred'.
  2. Helper. Same idea as _.matchesProperty('user', 'fred').
  3. Filter. Only fred’s row passes.
  4. Use. Clean shorthand for a single property test.

Example 4 — Default Identity

No argument (or null) returns the pass-through iteratee.

Lodash
var fn = _.iteratee();

fn(42);
// → 42

_.filter([0, 1, '', 'ok', null], _.iteratee());
// → [1, 'ok']
Try It Yourself

How It Works

  1. Default. Empty call → _.identity.
  2. Pass-through. fn(42) returns 42.
  3. Truthy filter. Falsy values (0, '', null) drop out.
  4. Why it matters. Lodash uses this when you omit a callback.

Example 5 — Collection Shorthand (No Wrap)

Lodash methods already apply iteratee rules — wrapping is optional.

Lodash
var users = [
  { 'user': 'barney', 'age': 36 },
  { 'user': 'fred',   'age': 40 }
];

_.map(users, 'user');
// → ['barney', 'fred']

_.map(users, _.iteratee('user'));
// → ['barney', 'fred']  // same result
Try It Yourself

How It Works

  1. Shorthand. _.map(users, 'user') is enough for everyday use.
  2. Explicit. Wrapping with _.iteratee documents the conversion.
  3. Same rules. Both paths use the property iteratee.
  4. When to wrap. Reuse a callback, or normalize input in your own API.

Browser & Runtime Support

_.iteratee is a Lodash Util helper since 4.0.0. It runs anywhere Lodash 4.x runs — modern browsers (CDN or bundle) and Node.js / Bun / Deno with npm install lodash.

✓ Stable · Lodash 4.0.0+

_.iteratee()

Available in [email protected] full builds and the lodash/iteratee modular import. Works in evergreen browsers and current Node LTS when Lodash is installed.

100% With Lodash 4.0+
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full support
_.iteratee Lodash 4.0.0+

Bottom line: Safe for production once Lodash 4+ is loaded. Prefer import iteratee from "lodash/iteratee" for smaller bundles. Collection methods already apply these shorthand rules for you.

Frequently Asked Questions

_.iteratee(value) turns a shorthand into a callback. A property name becomes a getter, an object becomes a partial-match predicate (_.matches), a [path, value] array becomes a path-equals check (_.matchesProperty), a function is returned as-is, and null/undefined becomes _.identity.
Usually no. Collection methods already convert shorthands internally—_.map(users, 'user') works without wrapping. Use _.iteratee() when you need to build, store, or reuse a callback, or when your own API must normalize input the Lodash way.
Functions (unchanged), property strings (e.g. 'user'), path arrays for matchesProperty (e.g. ['user', 'fred']), plain objects for matches (e.g. { active: true }), and null/undefined (identity).
_.iteratee('user') extracts a property value (good for map). _.iteratee({ active: true }) returns a predicate that checks partial equality (good for filter).
Calling _.iteratee() with no argument, or with null/undefined, returns _.identity—the default pass-through iteratee Lodash uses when a callback is omitted.
Use it to create reusable callbacks, normalize user-supplied field names in your helpers, document intent, or customize all Lodash iteratee shorthands by wrapping/replacing _.iteratee (advanced).

Next: _.matches()

Create a predicate that checks partial object equality.

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

10 people found this page helpful