SOURCE

function throttle(fn, delay) {
    let last = 0

    return function() {
        let context = this
        let args = arguments
        let now = +new Date()

        if (now - last >= delay) {
            last = now
            fn.apply(context, args)
        } 
    }
}

function dounble(fn, delay) {
    let timer = null

    return function() {
        let context = this
        let args = arguments

        if (timer) {
            clearTimeout(timer)
        }

        timer = setTimeout(function() {
          fn.apply(context, args)
        }, delay)
    }
}
console 命令行工具 X clear

                    
>
console