mqyqingfeng / Blog

冴羽写博客的地方,预计写四个系列:JavaScript深入系列、JavaScript专题系列、ES6系列、React系列。
30.69k stars 4.71k forks source link

您觉得第二版 绑定那里写成这样会不会更简洁一点呢 #184

Closed yusongmin closed 4 years ago

yusongmin commented 4 years ago

function debounce(func, await){

    var timer;
    return function(){

        var context = this;  
        clearTimeout(timer)
        timer = setTimeout(func.bind(this),await)
    }
}