Lodash _.get() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Object

Definition

Gets the value at path of object. If the resolved value is undefined, defaultValue is returned instead. Part of Lodash Object since 3.7.0 (stable — not deprecated).

Pass the object and path or keys shown below. Check whether the helper mutates or returns a new object.

Syntax

Call _.get. Start with this line.

Lodash
_.get(object, path, [defaultValue])
CallWhat it does
_.get(object, path, [defaultValue])Primary signature.
_.get(object)Work with an object’s keys, values, or paths.

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

Library declarations
Lodash
_.get(object, path, [defaultValue])

Parameters

ParameterDescription
objectRequired. The object to query
pathRequired. String or array path to the property
defaultValueOptional. Returned when resolved value is undefined

Return Value

Return ValueDescription
*Resolved value, or defaultValue

Lodash Examples

Example 1 — Official: Nested Path String

Bracket and dot notation walk arrays and objects safely.

Lodash
var object = { 'a': [{ 'b': { 'c': 3 } }] };

_.get(object, 'a[0].b.c');
// → 3
Try It Yourself

How It Works

  1. Start. Object has key a holding an array.
  2. Index. [0] selects the first element.
  3. Nest. .b.c walks into nested objects.
  4. Result. Resolved value is 3.

Example 2 — Array Path Segments

Same nested read using an array of path segments.

Lodash
var object = { 'a': [{ 'b': { 'c': 3 } }] };

_.get(object, ['a', '0', 'b', 'c']);
// → 3
Try It Yourself

How It Works

  1. Segments. Each array item is one path step.
  2. Index as string. "0" indexes the array at a.
  3. Same result. Matches the string-path version.
  4. Tip. Prefer arrays when a key itself contains dots.

Example 3 — Official: Default Value

When the path is missing, the default is returned.

Lodash
var object = { 'a': [{ 'b': { 'c': 3 } }] };

_.get(object, 'a.b.c', 'default');
// → 'default'
Try It Yourself

How It Works

  1. Path. a.b treats a as an object, but it is an array.
  2. Miss. Intermediate step resolves to undefined.
  3. Default. Third argument 'default' is returned.
  4. Note. Without a default, the result would be undefined.

Example 4 — null Does Not Trigger Default

Default applies only for undefined, not for null or other falsy values.

Lodash
var data = {
  nickname: null,
  score: 0,
  missing: undefined
};

_.get(data, 'nickname', 'guest');
// → null

_.get(data, 'score', 100);
// → 0

_.get(data, 'missing', 'n/a');
// → 'n/a'
Try It Yourself

How It Works

  1. null. Path exists with value null → default unused.
  2. 0. Falsy but defined → returned as 0.
  3. undefined. Resolved value is undefined → default used.
  4. Rule. Think “missing,” not “falsy.”

Example 5 — Safe on null / undefined Object

No throw when the root value is missing.

Lodash
_.get(null, 'a.b', 'fallback');
// → 'fallback'

_.get(undefined, ['user', 'name'], 'anon');
// → 'anon'

_.get({ user: { name: 'Ada' } }, 'user.name', 'anon');
// → 'Ada'
Try It Yourself

How It Works

  1. Null root. First step cannot continue → default.
  2. Undefined root. Same safe behavior.
  3. Valid object. Path resolves normally.
  4. Use. Ideal for API payloads that may be incomplete.

Browser & Runtime Support

_.get is a Lodash Object helper (available since 3.7.0, stable in 4.x). It runs anywhere Lodash runs — modern browsers (via CDN or bundle) and Node.js / Bun / Deno with npm install lodash.

✓ Stable · Lodash 3.7.0+

_.get()

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

100% With Lodash 4.x
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
_.get Lodash 3.7.0+

Bottom line: Safe for production once Lodash is on the page or in your bundle. Prefer import get from "lodash/get" for smaller builds. For static paths in modern JS, optional chaining is a lightweight alternative.

Frequently Asked Questions

_.get(object, path, [defaultValue]) gets the value at path of object. If the resolved value is undefined, defaultValue is returned instead.
Only when the resolved value is strictly undefined. null, 0, false, and "" are returned as-is.
A dotted string ("a.b.c"), bracket notation ("a[0].b"), or an array of segments (["a", "0", "b"]). Prefer arrays when a key contains dots or brackets.
Optional chaining needs a static path at compile time. _.get accepts dynamic string/array paths and a built-in defaultValue.
_.get returns defaultValue (or undefined). It does not throw.
Use import get from "lodash/get" or require("lodash/get"). Full build: import _ from "lodash" then _.get.

Next: _.has()

Check whether a path exists as an own property on an object.

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