JS防抖函数

export function fandou(callback = function() {}, timeout = 300) {
    let timer = null;
    return function() {
        const arg = arguments;
        const context = this;
        clearTimeout(timer);
        timer = setTimeout(() => {
            callback.apply(context, arg)
        }, timeout);
    }
}

您尚未收到任何评论。