I have the following code which iterates through a JS array. When I get to a specific element, I want to remove it. I realise that I can use splice, but is there a way that doesn't involve me tracking the index:
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
}
});