//封装节流函数
function throttle(callback,delay){
var last=0;
return function(){
arg=arguments;
var that=this
if(Date.now()-last>delay){
callback.apply(that,arg);
last=Date.now()
}
}
}
//防抖函数
function debounce(callback,delay){
var timerid=null;
return function(){
arg=arguments
var that=this
if(timerid){
clearTimeout(timerid)
}
timerid=setTimeout(()=>{
callback.apply(that,arg)
},delay)
}
}
function cc(num){
console.log(num)
}
//var moves=debounce(cc,1000)
var moves=throttle(cc,1000)
document.getElementById('box').addEventListener('click',()=>{
console.log('123')
moves(666)
},false)