I have an array of objects
x = [{id:null},{id:null},{id:null},{id:null}];
Lets say that the values for the array changed
x = [{id:1},{id:3},{id:8},{id:12}];
And i wanted to revert the values to all null,which method will be faster for performance
A) Reconstructing the array again
x=[];
for (var i=0; i<5; i++) {
var obj = {};
obj.id = null;
x.push(obj);
}
B) Resetting the values
for (var i in x) {
x.id = null;
}