在JAVAScript中通過數組和刪除項目循環並刪除項目
[1。在splice()(i = 0,len = auction.auctions.auctions.length; i 2。 Iterate in Reverse
By iterating through the array in reverse order, the re-indexing after splice() will not affect the remaining items in the iteration.var i = Auction.auctions.length 而(i--){ ... 如果 (...) { auction.auctions.splice(i,1); } }通過採用以下方法之一,您可以通過數組有效迭代並刪除項目而不會遇到未定義的值問題並確保循環過程的完整性。
免責聲明: 提供的所有資源部分來自互聯網,如果有侵犯您的版權或其他權益,請說明詳細緣由並提供版權或權益證明然後發到郵箱:[email protected] 我們會在第一時間內為您處理。
Copyright© 2022 湘ICP备2022001581号-3