Q1. How do you create animations in canvas?
Use requestAnimationFrame to repeatedly clear and redraw the canvas, updating positions each frame.
Q2. Why is clearRect needed in animation?
clearRect erases previous drawings before new frame, creating movement illusion.
Q3. What is requestAnimationFrame?
It tells browser to call a function before next repaint, creating smooth, efficient animations.
Q4. How do you update object position?
Change variables each frame (x += speed), then redraw at new position.
Q5. What happens without clearing each frame?
Previous drawings remain, creating a trail or smear effect.
