This question has already been answered:
If I create an array in such a way a=[1,2,12] , then I can run through the indices like for (var i in a) , but if I create an array using new Array , then the situation changes:
b=new Array(10); for(var i in b) console.log(i); forin stops running on array indices. What's wrong?
"use strict"; document.body.innerHTML = "for a: "; var a = [1, 2, 12]; for (var i in a) document.body.innerHTML += `${i} `; document.body.innerHTML += "<br>for b:"; var b = new Array(10); for (var i in b) document.body.innerHTML += `${i} `; UPD I will change the question a bit. You can create an array in two ways, get an equivalent result, but at the same time forin will work for these array in different ways. I will show it by example:
"use strict" var p=(s)=>document.body.innerHTML+=s; var x = [undefined, undefined, undefined]; var y = new Array(3); p(`${x.length} ${y.length}<br>`); for (var i=0; i<3; i++) p(`${x[i] === y[i]} `); p("<br>"); p("forin for x:"); for (var i in x) document.body.innerHTML += `${i} `; p("<br>forin for y:"); for (var i in y) document.body.innerHTML += `${i} `; It turns out in something all the same, these arrays are different. In what?
The console in chrome displays them in different ways.

bempty because - Herrgottalert(b)shows,,,,,,,,,,- Herrgott