// 节流 throttle
const fn = (x,y)=>{
console.log(x+y)
}
// const throttle = (fn,time)=>{
// let frezzle = null
// return (...agrs)=>{
// if(frezzle){return}
// fn.call(null,...agrs)
// frezzle = true
// setTimeout(()=>{
// frezzle = null
// },time)
// }
// }
// debounce
const debounce = (fn,time)=>{
let timer = null
return (...agrs)=>{
if(timer){clearTimeout(timer)}
timer = setTimeout(()=>{
fn.call(undefined,...agrs)
timer= null
},time)
}
}
// const a = throttle(fn,3000)
const a = debounce(fn,3000)
a('小方',100)
console