SOURCE

function debounce(func, wait){
  let tid = null;
  let context = this;
  return function(){
    if(tid){
      clearTimeout(tid)
    }
    tid = setTimeout(() => {
      func.call(context, arguments)
    }, wait)
  }
}

function throttle1(func, wait){
  let pre = 0;
  let context = this;
  return function(){
    let now = Date.now();
    if(now - pre > wait){
      func.call(context, arguments);
      pre = now;
    }
  }
}
function throttle2(func, wait) {
    let tid;
    return function() {
        let context = this;
        let args = arguments;
        if (!tid) {
            tid = setTimeout(() => {
                tid = null;
                func.apply(context, args)
            }, wait)
        }

    }
}
console 命令行工具 X clear

                    
>
console