I've a following code snippets ,
poupulateData(data) {
//lets assume variable data is an array of objects with more 400 data
let arr = [];
let obj;
if (data && data.length) {
for (let i = 0; i < data.length; i++) {
obj= data[i];
arr.push(obj.features);
}
}
}
I've declared variable obj outside loop , and in the following code snippets i'm going to declare obj inside the loop , like this
poupulateData(data) {
//lets assume variable data is an array of objects with more 400 data
let arr = [];
if (data && data.length) {
for (let i = 0; i < data.length; i++) {
let obj= data[i];
arr.push(obj.features);
}
}
}
the memory allocation for variable obj will be released after the end of the loop , so i want to know which is best in terms of memory allocation and performance if the collection is big