Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lodash.get

Package Overview
Dependencies
Maintainers
3
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lodash.get

The lodash method `_.get` exported as a module.

  • 4.4.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
14M
increased by1.91%
Maintainers
3
Weekly downloads
 
Created

What is lodash.get?

The lodash.get package is a method from the Lodash library that allows for safe access to nested object properties. It helps in avoiding errors when querying for deeply nested properties in an object that may or may not exist.

What are lodash.get's main functionalities?

Accessing Nested Object Properties

Safely access nested object properties using a string path.

const object = { 'a': [{ 'b': { 'c': 3 } }] };
const value = _.get(object, 'a[0].b.c');
console.log(value); // => 3

Default Values

Provide a default value if the resolved value is undefined.

const object = { 'a': [{ 'b': { 'c': 3 } }] };
const value = _.get(object, 'a[0].b.d', 'default');
console.log(value); // => 'default'

Accessing Properties with Dynamic Paths

Use an array to specify the path for properties, allowing for dynamic path construction.

const object = { 'a': [{ 'b': { 'c': 3 } }] };
const path = ['a', '0', 'b', 'c'];
const value = _.get(object, path);
console.log(value); // => 3

Other packages similar to lodash.get

Keywords

FAQs

Package last updated on 13 Aug 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc