SOURCE

console 命令行工具 X clear

                    
>
console
function debounce(fn, s) {
  let timer;
  return function() {
    clearTimeout(timer);
    let _this = this;
    let args = arguments;
    timer = setTimeout(() => {
      console.log(args)
      return fn.apply(_this, args);
    }, s)
  }
}

var test = debounce(function() {
  console.log('触发点击')
}, 500)

document.getElementById('test').addEventListener('click', test)
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <title>Document</title>
</head>
<body>
  <div>
    <button id='test'>点我呀</button>
  </div>
</body>
</html>