Lodash _.at() method

Beginner
⏱️ 6 min read
📚 Updated: May 2026
🎯 3 Code examples
🚀 3 Try-it labs
Lodash

What you’ll learn

  • How _.at(object, [paths]) plucks several values in one call and returns them as an array.
  • Three path styles: dotted string, array-of-keys, and rest arguments—and when each matters.
  • When to reach for _.at vs _.get() (single path) or _.pick() (sub-object).
  • Try each example in the editor (?tryit=1, 2, 3) with Lodash from a CDN.

Prerequisites

Familiar with dotted/array paths in Lodash (the shared model used by _.get, _.set, and friends).

  • Nested objects: walking shapes like { user: { address: { city } } } via "user.address.city".
  • Array destructuring: downstream code often unpacks the result as const [name, city, email] = _.at(...).

Overview

_.at is a multi-_.get: hand it an object and any number of paths, and it returns the values as an array in the same order. The result is always an array—perfect for positional destructuring.

Pluck many at once

Avoid a chain of _.get calls when you need three or four fields out of a record.

Order preserved

Slot N in the result is the value at path N—missing paths still take their slot as undefined.

Array path escape hatch

When a key contains a dot, pass it as an array path—[["weird.key"]]—so Lodash doesn’t split on it.

Syntax

javascript
_.at(object, [paths])
// paths can be a single string, an array of strings/paths, or several rest args.
  • object: source object (or array) to read from.
  • paths: one or more paths. Each path is a dotted string ("user.email") or an array of keys (["user", "email"]).
  • Returns: an array of values, one per input path, in input order. Missing paths produce undefined.
1

Pluck a few fields out of a record

Three paths in, three values out, in the same order. Great for positional destructuring.

javascript
import at from "lodash/at";

const user = {
  id: 1,
  name: "John Doe",
  address: { city: "New York", zip: "10001" },
  email: "john@example.com"
};

const [name, city, email] = at(user, ["name", "address.city", "email"]);
// name  -> "John Doe"
// city  -> "New York"
// email -> "john@example.com"
Try it Yourself
2

Missing paths keep their slot

The result array always has one entry per requested path; absent values come back as undefined so indexes stay aligned with your input.

javascript
import at from "lodash/at";

const user = { name: "John", address: { city: "NY" } };

at(user, ["name", "address.country", "phone"]);
// => [ "John", undefined, undefined ]
//      ^^^^^^   ^^^^^^^^^^^^^^^^^^^   ^^^^^^^^^
//      hit      missing nested        missing top-level
Try it Yourself
3

Array paths for tricky keys & array indexes

When a key literally contains a dot, hand _.at an array path so it doesn’t split. Numeric segments also work on arrays.

javascript
import at from "lodash/at";

const data = {
  "my.weird.key": "got it",
  tags: ["alpha", "beta", "gamma"]
};

at(data, [["my.weird.key"], "tags[0]", "tags.2"]);
// => [ "got it", "alpha", "gamma" ]
//      ^^^^^^^^   ^^^^^^^   ^^^^^^^
//      array path bracket   dotted index
Try it Yourself

📋 _.at vs _.get vs _.pick

Topic_.at_.get_.pick
Paths per callOne or manyOneOne or many (keys/paths)
Return shapeArray of valuesA single valueA new object
Missing pathundefined slotdefaultValue if provided, else undefinedKey simply omitted
Typical usePositional destructure of many fieldsOne safe deep read with a defaultFilter to a sub-object DTO

Reach for _.at when downstream code wants positional access; pick _.pick when it wants the keys preserved.

Pitfalls to avoid

No defaults

Missing paths surface as undefined

_.at has no equivalent of _.get’s third argument. Map the result yourself if you need fallbacks per path.

Dotted keys

Accidental key splitting

Dotted strings split on every dot. Wrap literal dotted keys in an array path so Lodash treats them as a single segment.

Shape

Confusing with _.pick

_.at always returns an array; _.pick returns an object. Pick the API that matches the consumer’s shape expectation.

❓ FAQ

Always an array. Each slot in the returned array corresponds to the path at the same index in the input. Missing paths produce undefined; the array length always equals the number of paths.
_.get reads one path and returns the value (or a default). _.at reads one OR many paths in one call and returns an array of values—ideal for plucking several fields at once.
_.pick builds an object of only the requested keys: { name, email }. _.at returns an array of values in path order: [name, email]. Pick when you need a sub-object; at when you want to destructure into positional variables.
Yes—pass that path as an array. _.at(obj, [['my.key']]) treats 'my.key' as a single property name instead of splitting on the dot.
Yes. _.at(obj, 'a', 'b.c') and _.at(obj, ['a', 'b.c']) produce the same result. The rest-style form is convenient when paths are known up front.
Use import at from "lodash/at"; for ESM or const at = require('lodash/at') in CommonJS.

Summary

  • Purpose: pluck one or more values from an object by path; result is always an array in path order.
  • Remember: missing paths become undefined slots; wrap dotted-name keys in array paths; no per-path default.
  • Next: Lodash _.create(), _.get(), or the official Lodash docs for _.at.
Did you know?

_.at always returns an array, even for a single path—the result’s position lines up with the path’s position. To address a key that literally contains dots, wrap it in an array path: _.at(obj, [["weird.key"]]).

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.

6 people found this page helpful