JavaScript throttle
function throttle(func, delay){
let inThrottle;
let timeout = null;
return function(){
let context = this;
let args = arguments;
if(!inThrottle){
func.apply(context, args)
inThrottle = true;
clearTimeout(timeout);
timeout = setTimeout(function(){
inThrottle = false
}, delay)
}
}
}