Merge nested array in object in Javascript
<p>I need to merge 2 objects with nested arrays</p>

<pre><code>var dest = {
  id: "865",
  arr: [{
    id: "123",
    value: "First" }]
};

var src = {
  id: "865",
  arr: [{
    id: "456",
    value: "Second" }]

};
</code></pre>

<p>to produce</p>

<pre><code>merge = {
  id: "865",
  arr: [{id: "123",
         value: "First"},
        {id: "456",
         value: "Second"}]
};
</code></pre>

<p>I tried using _.merge(dest, src) (using Lodash) and a couple of other methods, but seems like the 2nd object is overwriting the first one because it doesn't handle the nested array the way I want.</p>

<p>What is the best way to do this?</p>

<p>Thanks,</p>