Can anyone explain why the value of ColumnNames
changes at the debugger breakpoint in the code snippet below? It seems to take on the same value as tempColumns
after
tempColumns[k] = modi[i].data[k];
.
var addRecords= [];
var columns = ["Column1","Column2","Column4","Column5"]
var columnNames = {};
var modi = [{
data: {
Column1: 'bla'
}
},{
data:{
Column2: 'test'
}
}];
var tempColumns = {};
for( var n in columns){
var column = columns[n];
columnNames[column] = "";
}
for(var i in modi){
tempColumns = columnNames;
for(var k in modi[i].data){
tempColumns[k] = modi[i].data[k];
debugger;
}
addRecords.push(tempColumns);
}