JS节流与防抖
节流
function throttle(fn, time) {
let timer;
return function(){
const args = arguments;
const _that = this;
if(timer) {
return;
}
timer = setTimeOut(() => {
fn.call(_that, args);
timer = null;
}, time);
}
}防抖
Last updated