Socket
Socket
Sign inDemoInstall

lodash.get

Package Overview
Dependencies
0
Maintainers
3
Versions
13
Alerts
File Explorer

Advanced tools

Install Socket

Protect your apps from supply chain attacks

Install

lodash.get

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

    4.4.2latest
    GitHub
    npm

Version published
Maintainers
3
Weekly downloads
12,164,831
increased by2.02%

Weekly downloads

Package description

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

Readme

Source

lodash.get v4.4.2

The lodash method _.get exported as a Node.js module.

Installation

Using npm:

$ {sudo -H} npm i -g npm
$ npm i --save lodash.get

In Node.js:

var get = require('lodash.get');

See the documentation or package source for more details.

Keywords

FAQs

Last updated on 13 Aug 2016

Did you know?

Socket installs a GitHub app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc