Skip to content

Instantly share code, notes, and snippets.

@jpitchardu
Created May 23, 2018 16:38
Show Gist options
  • Save jpitchardu/6939caa6ad0d26a79c23f628f90cc04f to your computer and use it in GitHub Desktop.
Save jpitchardu/6939caa6ad0d26a79c23f628f90cc04f to your computer and use it in GitHub Desktop.

Revisions

  1. jpitchardu created this gist May 23, 2018.
    7 changes: 7 additions & 0 deletions lodash-get.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    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'