Created
September 11, 2017 18:56
-
-
Save khaosdoctor/c45c8a498def4a55af408c8b1f8fb6b3 to your computer and use it in GitHub Desktop.
Lodash Get
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var _ = require(‘lodash’) | |
var object = { ‘a’: [{ ‘b’: { ‘c’: 3 } }] }; | |
_.get(object, ‘a[0].b.c’); | |
// => 3 | |
_.get(object, [‘a’, ‘0’, ‘b’, ‘c’]); | |
// => 3 | |
_.get(object, ‘a.b.c’, ‘default’); | |
// => ‘default’ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment