我要说的是,我有10 000名随机分类的愤怒。 在通过该守则时,我想逐个增加<条码>。 如果我这样做的话,那是:
const myArray = [/* 10000 totally random integers! */];
let pos = 0;
while (pos < myArray.length) {
document.getElementById("unorderedList").innerHTML += `<li>${pos}</li>`;
pos++;
}
console.log("done!");
It freezes the whole window until it finishes, then it logs everything. How can I make it so the loop adds the number every iteration until it finishes instead of finishing the loop then printing everything?
Note: this hypothetical function also needs to interact with a Window
created with window.open
, so I don t think I can use workers since that interacts with the DOM.