JavaScript简单的防抖函数

直接上代码:

function debounce(fn, time) {
    return function(args) {
        let that = this
        clearTimeout(fn.tid)
        fn.tid = setTimeout(() => {
            fn.call(that, args)
        }, time);
    }
}