优化前代码
var i = 0;
window.addEventListener('scroll',function(){
console.log(i++);
},false);
var debounce = null;
window.addEventListener('scroll',function(){
if(debounce){
clearTimeout(debounce);
}
debounce = setTimeout(function(){
console.log("scroll");
},500);
})