title: How to merge array of objects in one object, including inner objects - JavaScript?
body: <p>Suppose I have the following array of objects:</p>
  
  <pre><code>var list = [
    { a: 1, 
      b: { c: 'x', k: []}
    },
    { a: 1,
      b: {c: 'x', d: 8}
    }
  ];
  </code></pre>
  
  <p>I want them to be merged into one "generic" object, for this example, it would be:</p>
  
  <pre><code>{a: 1, b: {c: 'x', d:'8', k[]}}
  </code></pre>
  
  <p>As you can see, all nested objects are merged too. But I can't gain it. If I use Object.assign it creates new nested objects if they are different, that is duplicates them:</p>
  
  <pre><code>var res = Object.assign({}, ...list);
  // res: {
      a: 1, 
      b: {c: 'x', k: []},
      b: {c: 'x', d: 8}
  }
  </code></pre>