Creating a dynamic array
<p>I need to create a dynamic array with a loop.. but I cant seem to get the desired results.</p>

<p>the array I want is: </p>

<pre><code>{
    "CategoryName": "somecategoryname",
    "Date": "02-17-2012",
    "Id": 24,
    "ProductToHide": [
        {
            "IsHide": true,
            "ProductId": "someid"
        }
    ],
    "ProductsToAdd": [
        {
            "MealSequence": "S1",
            "ProductId": "Someid"
        },
        {
            "MealSequence": "S2",
            "ProductId": "Snack_11"
        }
    ],
    "UserId": "1"
}
</code></pre>

<p>and I am using the following function to add products: </p>

<pre><code>addProduct: function(id){
        var tempArr = [];
        $.each(this.mCData.ChildCategories, function(i, item){
            $.each(item.PList, function(j, jsonPr){
                if (jsonPr.TID == id){
                    addProduct = new mealTypeProduct();
                    addProduct.data = jsonPr;
                    tempArr = addProduct.modifyProduct();
                }   
            })
        })

    //  queryStr = {"add" : tempArr};
    //  this.modificationArray.push(queryStr);
        this.modificationArray['add'].push(tempArr);    
        console.log(this.modificationArray);
    }
</code></pre>

<p>Its giving me the following error: </p>

<pre><code>this.modificationArray.add.push is not a function
this.modificationArray['add'].push(tempArr);
</code></pre>

<p>the initializing is done in the following manner: </p>

<pre><code>var mealType = {
    chosenDate: new Date(), tabViewHtml: '',
    modificationArray: [], saveArray: [],
}
</code></pre>

<p>What am I doing wrong?</p>
