防抖
function debounce(fn,t){
let time
return function () {
if(time) clearTimeout(time)
time=setTimeout(function(){
fn()
},t)
}
}
节流
function throttle(fn,t){
let time=0
return function (){
now=Date.now()
if(now-time>=t) {
fn()
}
time=now
}}