function throttle(fn, delay) { let timeout = null; return function() { const ctx = this; const args = arguments; if (timeout) return; fn.apply(ctx, args); timeout = setTimeout(() => { timeout = null; }, delay); } } function hello() { console.log('hello'); } const delayedHello = throttle(hello, 1000); setInterval(() => { delayedHello(); }, 50);