const debounce = (func, delay = 500) => { let timer = null; return function () { clearTimeout(timer) timer = setTimeout(() => { func.apply(this, arguments) }, delay) } } const pay = (money = 100) => { console.log('money:' + money) } const test = debounce(pay) test(20) test(30) setTimeout(() => { test(40) }, 1000)