SOURCE

console 命令行工具 X clear

                    
>
console
function debounce (fn, delay) {
    let timer;
    return function (...args) {
        if (timer) {
            clearTimeout(timer);
        }
        timer  = setTimeout(() => {
            fn.apply(this, args)
        }, delay)
    }
}

window.addEventListener('mousemove', debounce(function () {
    console.log('行为结束1秒后再运行的')
}, 1000))
<div class="tip">
    <p class="title">防抖</p>
    <div>
        点击右下角
        <span class="sp">Console</span>
        查看运行结果
    </div>
</div>
.tip {
    background-color: rgba(174,220,174,0.25);
    padding: 0.75rem;
    border-left: 0.35rem solid;
    border-radius: 0.25rem;
    margin: 1.5rem 0;
    font-size: 0.9rem;
    border-color: #5cb85c;
}

.title {
    font-size: 18px;
    font-weight: bolder;
    margin-top: 0;
}

.sp {
    background: orange;
}