防抖
function debounce(fun,time){
let timer
return function(){
clearTimeout(timer)
timer=setTimeout(()=>{
fun.apply(this,arguments)
},time)
}
}
节流
```javascript
function throttle(fun,time){
let canRun = true
return function(){
if(!canRun) return
canRun=false
setTimeout(()=>{
fun.apply(this,arguments)
canRun = true
},time)
}
}