Extending an object ( nesting )
<p>In a section object, I have a <code>CategoryId</code> - like a foreign key.
Now, I would like to copy each section into the matching category object.</p>

<p>Source:</p>

<pre><code>var sections = [{title:"FirstSection", CategoryId : 1},
                {title:"SecondSection", CategoryId : 1}, 
                {title:"ThirdSection", CategoryId : 2}];
var categories = [{title:"Cat1", Id : 1},
                 {title:"Cat2", Id : 2}];
</code></pre>

<p>The result would look like this:</p>

<pre><code>categories = [{title:"Cat1", 
               Id : 1, 
               sections : [{title:"FirstSection", CategoryId : 1},
                           {title:"SecondSection", CategoryId : 1}]
              },
              {title:"Cat2", 
               Id : 1, 
               sections: [{title:"ThirdSection", CategoryId : 2}]
              }];
</code></pre>

<p>All sections with <code>CategoryId = 1</code> are now in a sections array of the category with Id = 1.</p>

<p>Maybe I am searching for the wrong keywords, but I can not find a solution for this. </p>
