我有以下代码遍历 JS 数组。当我到达特定元素时,我想将其删除。我意识到我可以使用拼接,但有没有一种方法不涉及我跟踪索引:
myArray.forEach(function (point) {
canvasContext.clearRect(point.PointX - 3, point.PointY - 3, 6, 6);
point.PointY++;
canvasContext.fillRect(point.PointX - 3, point.PointY - 3, 6, 6);
if (point.PointY > canvas.height) {
// Remove point
}
});