感覺js高程中對于節流的定義和平常看到的博客中對于節流的定義不太一樣呢?感覺這個定義像是防抖,跟underscore中的debounce方法類似,而且我也偏向于認為這種思想稱為防抖,請大佬指正這是高程中對于節流的定義和代碼function throttle(method, context) {
clearTimeout(method.tId);
method.tId= setTimeout(function(){ method.call(context);
}, 100);
}一些博客里看到的對于防抖的定義和實現//防抖的代碼實現function debounce(fn, delay){ let timer = null; return function() { let context = this; let args = arguments;
clearTimeout(timer);
timer = setTimeout(function(){
fn.apply(context, args);
}, delay)
}
}
javascript高級程序設計中對于節流定義怎么像防抖呢?
互換的青春
2018-09-04 15:58:41