title: How to prevent lodash map from creating a nested object?
body: <p>I want to map an array of objects and add a property to each item. At the moment the original values get nested. How can I change it to get an item with a flattened object?</p>
  
  <p><a href="https://repl.it/repls/FewHarshForce" rel="nofollow noreferrer">code example</a></p>
  
  <pre><code>import _ from 'lodash';
  
  let arr = [{name: "tim"}, {name: "tom"}]
  const id = {id: 1}
  
  console.dir(_.map(arr, item =&gt; ({...id, item}))); 
  </code></pre>
  
  <p>result:</p>
  
  <pre><code>[ { id: 1, item: { name: 'tim' } },
    { id: 1, item: { name: 'tom' } } ]
  </code></pre>
  
  <p>wished result:</p>
  
  <pre><code>[ { id: 1,  name: 'tim'  },
    { id: 1,  name: 'tom' } ]
  </code></pre>