const debounce =(fn,delay)=>{
let timer = null
return function(){
if(timer) clearTimeout(timer)
timer = setTimeout(()=>{
fn.call(this,...arguments)
},delay)
return [].slice.call(arguments)
}
}
const fun =(a)=>{
console.log(a)
}
const db = debounce(fun,1000)
console.log(db(11),11)
console.log(db(22),22)
console.log(db(33),33)
const throttle =(fn,delay)=>{
let timer = null
return function(){
if(!timer){
timer = setTimeout(()=>{
fn.call(this,...arguments)
clearTimeout(timer)
},delay)
}
}
}
const tt = throttle(fun,1000)
console.log(tt(11),11)
console.log(tt(22),22)
console.log(tt(33),33)
console