SOURCE

function throttle(fn, delay) {
    let preTime = new Date().getTime();
    return function () {
        const curTime = new Date().getTime();
        const context = this;
        if (curTime >= (preTime + delay)) {
            fn.apply(context, arguments);
            preTime = curTime;
        }
    }
}
let n = 0;
function test() {
    n++;
    console.log(n);
}

const delayTestFn = throttle(test, 1000);
setInterval(function(){
    delayTestFn();
},10);
console 命令行工具 X clear

                    
>
console