I'm wondering if it is more efficient to place any vars referenced within a loop, outside of the loop - or can they get garbage collected like vars inside of a function?
var obj = {key:'val'};
for(var i=0; i<10; i++){
console.log(obj);
}
or
for(var i=0; i<10; i++){
var obj = {key:'val'};
console.log(obj);
}
I tried to run some memory test in my browser's profiler but still couldn't tell which method was better.