JavaScript专题之跟着 underscore 学节流
2018-11-22 本文已影响0人
__越过山丘__
https://github.com/mqyqingfeng/Blog/issues/26
function throttle(func, wait) {
var timeout;
var previous = 0;
return function() {
var context = this;
var args = arguments;
if (!timeout) {
timeout = setTimeout(function(){
timeout = null;
func.apply(context, args)
}, wait)
}
}
}