javascript – How to clear an area of ​​the canvas?

Question:

I created a function that generates random objects in the canvas area and I wanted the area to be cleaned after the end of this function.

Is there any possibility to do this?

Answer:

Try like this:

context.clearRect(0, 0, canvas.width, canvas.height);

Reference:

Scroll to Top