JavaScript日常学习

防抖函数

`

export cosnt _debounce = (fn, defaultTime) => {
    let timer = defaultTime || 200
    let timerFn
    return function () {
       let _that = this
       if (timerFn) {
        clearTimeout(callBack)
       } else {
         timerFn = setTimeout(() => {
            callBack = null
            fn.apply(_that, args)
         }, timer)
       }
    }
}

`

你可能感兴趣的:(javascript,es6)