SOURCE

function debounce(callback,time){
    let t;
    return function(){
        clearTimeout(t);
        t = setTimeout(callback,time);
    }
}
function foo(){
    console.log("调用了一次");
}
window.onclick = debounce(foo, 2000);
console 命令行工具 X clear

                    
>
console