title: How to move specific key value inside another array object in javascript
body: <p>I have array object <code>obj</code> how to move particular key value <code>store</code> inside another array <code>items</code> in javascript.
  I would like to know how to pass particular key value inside another array in javascript</p>
  
  <pre><code>var obj = [
    {
     id:1,
     store: "10",
     items: [{name:"sample1", total: 20}, {name:"sample2", total: 10}] // add store
    },
    {
     id:1,
     store: "11",
     items: [{name:"sample3", total: 10}, {name:"sample4", total: 10}] // add store
    }
  ]
  
  function newarray(obj){
   return obj.map(e=&gt;...e,e.items.map(i=&gt;{...i,store: e.store })
  }
  
  </code></pre>
  
  <p>Expected Output</p>
  
  <pre><code>[
    {
     id:1,
     store: "10",
     items: [{name:"sample1", total: 20, store: "10"}, {name:"sample2", total: 10, store: "10"}]
    },
    {
     id:1,
     store: "11",
     items: [{name:"sample3", total: 10, store: "11"}, {name:"sample4", total: 10, store: "11"}] 
    }
  ]
  
  </code></pre>