Within my AngularJS controllers, I have initialized two variables:
_this.currentData=new Array();
_this.masterCurrentData=new Array();
Later on, I created a temporary array of objects called tmpDataSort and populated it separately using loops.
var tmpDataSort=[{
"values":new Array(),
disabled: false,
"key":"Retail"
},{
"values":new Array(),
disabled: true,
"key":"Commercial"
},{
"values":new Array(),
disabled: true,
"key":"Industrial"
},{
"values":new Array(),
disabled: true,
"key":"Residential"
}]
_this.masterCurrentData=tmpDataSort;
_this.currentData=tmpDataSort;
tmpDataSort=null;
However, I noticed that whenever I perform an operation on Current Data, the value of MasterCurrentData changes even though I never explicitly use masterCurrentData.
_this.modifyCurrentBean = function(locName, selectFlag){
console.log(_this.masterCurrentData[0].values)
for(var i=0;i<_this.currentData.length;i++){
for(var j=0;j<_this.currentData[i].values.length;j++){
if(_this.currentData[i].values[j].x==locName){
_this.currentData[i].values.splice(j,1);
break;
}
}
}
console.log(_this.masterCurrentData[0].values)
}
The first console shows [object object] and the second console show only a single [object]