JS: Module 7

← Dashboard
Module 7: The Creative Motion

Timers & Animation

setTimeout and setInterval for delayed/repeating code. Trigger CSS animations from JS. Intro to Canvas for drawing.

// Wait 2 seconds, then run
setTimeout(() => pourCoffee(), 2000);

// Repeat every 1 second
const id = setInterval(updateTimer, 1000);
clearInterval(id);  // stop

// Trigger CSS animation
el.classList.add('animate-pulse');
Pro Tip

Store setTimeout/setInterval IDs so you can clear them and avoid memory leaks.

Canvas

Canvas API lets you draw shapes, images, and animations with JavaScript.