Throttles a function. Throttle will run a function immediately when it's called and wait X amount of seconds before it can be called again.
const throttler = func.throttle((windowEvent)=> { console.log(wiindowEvent);}, 500);// Now when you resize, it will immediately call the throttle function// and wait 500 ms before it can be called again.window.addEventListener('resize', throttler);Or just:window.addEventListener('resize', func.throttle(()=> { console.log('throttled');}, 500)) Copy
const throttler = func.throttle((windowEvent)=> { console.log(wiindowEvent);}, 500);// Now when you resize, it will immediately call the throttle function// and wait 500 ms before it can be called again.window.addEventListener('resize', throttler);Or just:window.addEventListener('resize', func.throttle(()=> { console.log('throttled');}, 500))
The callback function
The amount to wait in ms.
Throttles a function. Throttle will run a function immediately when it's called and wait X amount of seconds before it can be called again.