I used the method described here:
How do I empty an array in JavaScript?
to reset an array in my code.
My code is such
var check = new Array();
var i = 0;
if(some statements){
check[i]=something;
i=+1;
}
function reset(){
check.length=0;
}
After executing of if statement, if I console.log()
, the array is displayed as such
["abc","def","ghi"]
. Then the reset function is called.
After that, the next time the array is used, it logs as follows:
[1: "abc", 2: "def", ...]
What can I do to make it reset to original empty array?