setTimeout(), setInterval(), and requestAnimationFrame()
How does this timing pattern differ from debouncing?
function throttle(fn, delay) {
let lastCall = 0;
return function(...args) {
const now = performance.now();
if (now - lastCall >= delay) {
fn.apply(this, args);
lastCall = now;
}
};
}