I ran the following JS code. Console prints an empty array.
function xyz(){
var a=[]; var b=[];
console.log(a);
for(i=0;i<10;i++){
b.push(i);
}
a=b;
}
function xyz(){
var a=[];
console.log(a);
for(i=0;i<10;i++){
a.push(i);
}
}
the console prints the array from 0 to 9. Also, I see here that even though the console statement is above the for loop where we are pushing the values in the array, but still the console is printing but not in the first case (which i think is because the reference which console is printing is empty).Code was tested on chrome browser console.
