感覺(jué)js高程中對(duì)于節(jié)流的定義和平??吹降牟┛椭袑?duì)于節(jié)流的定義不太一樣呢?感覺(jué)這個(gè)定義像是防抖,跟underscore中的debounce方法類似,而且我也偏向于認(rèn)為這種思想稱為防抖,請(qǐng)大佬指正這是高程中對(duì)于節(jié)流的定義和代碼function throttle(method, context) {
clearTimeout(method.tId);
method.tId= setTimeout(function(){ method.call(context);
}, 100);
}一些博客里看到的對(duì)于防抖的定義和實(shí)現(xiàn)//防抖的代碼實(shí)現(xiàn)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高級(jí)程序設(shè)計(jì)中對(duì)于節(jié)流定義怎么像防抖呢?
互換的青春
2018-09-04 15:58:41