function throtle_1(fn, delay) {
let timer;
return function() {
let context = this;
let args = arguments;
if(timer) {
return
}
timer = setTimeout(function() {
fn.call(context, args);
timer = null;
}, delay)
}
}
function throtle_2(fn, delay) {
let pre = 0;
return function() {
let context = this;
let args = arguments;
let now = new Date();
if(now - pre > delay) {
fn.call(context, args);
pre = now;
}
}
}