SOURCE

function throttle(func, delay) {
    let lastTime = 0;
    return function(...args) {
        const now = Date.now();
        if (now - lastTime >= delay) {
            lastTime = now;
            func.apply(this, args);
        }
    };
}
const log = throttle(()=> console.log('1'),1000)
log()
log()
log()
log()
console 命令行工具 X clear

                    
>
console