I have to delete a shape in canvas.
The following code was written-
function deleteCircle(circle, propName) {
for( i = 0; i < circle.length; i++) {
circle[i].erase();
}
}
circle.prototype.erase=function() {
delete this;
}
when i am running this code at i=0 it is going to the erase function.
but after the frst delete it is not coming back to deletecircle.
This is just a rough code… i m just coonfused that after delete this…. that is after the object is deleted doest the code come back to deletecircle ?
As other users have said, modifying size of your array during the loop is a bad idea.
Try:
LIVE DEMO
EDIT: Sorry didn’t notice you changed the code. Updated:
LIVE DEMO