I stumbled upon a discussion about clearing an array in JavaScript, but unfortunately I can't participate there. So, here's my query: I have the following code snippet:
sumarray.length=0;
sumarray = [];
for (var i=0; i<3; i++)
sumarray.push(i);
console.log('***1***:',sumarray.length, sumarray);
var t;
while (console.log('***2***: t:',t=sumarray.pop()) || t!==undefined) {
console.log('***3***:',sumarray.length,sumarray);
}
console.log('*****4***: ',sumarray.length, sumarray);
After running this code, here is what I observed in the log:
I did not assign the global sumarray array to any other variable. How can I effectively clean out all unwanted elements from it? Any insights would be greatly appreciated.