感觉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)
}
}
互换的青春
牧羊人nacy
慕森王
随时随地看视频慕课网APP
相关分类