//防抖:用户触发过于频繁,我们只在最后一次才触发函数
//防抖函数的实现
function debounce(callback,delay){
let timer = null
return function(){
if(timer !== null){
clearTimeout(timer)
}
timer = setTimeout(()=> {
callback.call(this)
},delay)
}
}