反抖函数

function debounce(fn, delay) {
  let timer = null
  return function(...args) {
  if(timer) clearTimeout(timer)  
  let _this = this
  timer = setTimeout(() => {
    fn.apply(_this, args)
  }, delay)
}

你可能感兴趣的:(反抖函数)