javascript 函数节流方法

函数节流可以缓解调用的次数,代码如下:

function throttle(method,delay){ var timer=null; return function(){ var context=this, args=arguments; clearTimeout(timer); timer=setTimeout(function(){ method.apply(context,args); },delay); } }

原文地址:https://www.cnblogs.com/rongfengliang/p/4552180.html