saparate object to array of object : <p>i dont know how to make for loop to create new array of object with javascript coding</p>

<p>here i have some object like this</p>

<pre><code>item :[
{
 res_name: 'a',
 id: 1,
 name: name1
},
{
 res_name: 'b',
 id: 2,
 name: name2
},
{
 res_name: 'b',
 id: 3,
 name: name3
}
]
</code></pre>

<p>i want to change to array of object like this</p>

<pre><code>product:[
{
   res_name: 'a',
   product:[
    {
      id: 1,
      name: name1
    }
   ]
},
{
   res_name: 'b',
   product:[
    {
      id: 2,
      name: name2
    },
    {
      id: 3,
      name: name3
    }
   ]
}
]
</code></pre>

<p>can someone help me</p>
