SOURCE

// 防抖
const debounce = function (fun, delay) {
    let timer
    return function (...args) {
        if (timer) {
            clearTimeout(timer)
            timer = setTimeout(fun, delay, ...args)
        }
    }
}

// 节流
const throttle = function (fun, delay) {
    let open = true
    return function (...args) {
        if (open) {
            fun.call(this, ...args)
            open = false
            setTimeout(() => {
                open = true
            }, delay)
        } 
    }
}

console 命令行工具 X clear

                    
>
console