function _throttle(fn,t) { let timer = null return function () { if(!timer){ timer = setTimeout(() => { fn(); timer = null; }, t); } }; } window.addEventListener('mousemove', _throttle(function(){ console.log(1); },2000));