Hello everybody!!
Following up on the clearRect method by @miro.vasil, I have one more way for you @klyni_gg.
The trick is to reset the canvas.width or height property. This action automatically clears the content:
JavaScriptcanvas.width = canvas.width;
This basically forces the canvas to reset its entire state, effectively clearing everything drawn on it. However, do be cautious, resetting the size also resets transformations and applied styles, so you might need to reapply those after the clear operation.
Hope this alternative method offers another tool for your canvas manipulation, just remember its side effects!
Thanks