I am trying to create an array of objects, however when I am pushing onto my array it is adding a reference to the object rather than copying the values.
var nestedOrgList = [];
var tempTopOrg = {};
var i = 0;
while (typeof divList[i] !== 'undefined') {
    tempTopOrg.org = divList[i++]; // increment i after we assign this
    tempTopOrg.suborgs = [];
    while ($(divList[i]).has('.expand').length < 1 && i < divList.length) {
        tempTopOrg.suborgs.push(divList[i++]);
    }
    nestedOrgList.push(tempTopOrg);
};
Is there a better way to do this? Or do I need to do a manual copy?
nestedOrgList[insertIndex].org = tempTopOrg.org;
// etc..
insertIndex++;
 
     
     
     
     
     
    