我有一個if語句內的for循環,其循環通過整個陣列,並顯示的元素:卸下最後一項陣列,刪除整個陣列
for (var i = 0; i < txtA.length; i++) {
txtA[i].update();
txtA[i].show();
if (txtA[i].y == height) {
txtA.pop();
console.log(txtA.length);
}
}
的,如果相比於畫布語句檢查元件高度並刪除元素。問題是當if語句等於true時,數組中的所有元素都被刪除。幫幫我!
我們還可以看到您正在使用的陣列嗎? –
你確定數組有一個以上的元素開始? – Carcigenicate
該數組包含多個對象構造函數,並帶有x,y,letter,update()和show(); – RomanK