lodash array merge code example

Example 1: lodash merge

import merge from 'lodash/merge'

let object = {  'a': [{ 'b': 2 }, { 'd': 4 }]}; 
let other = {  'a': [{ 'c': 3 }, { 'e': 5 }]}; 
merge(object, other); // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }

Example 2: get 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'

Tags:

Misc Example