重复执行函数
function repeat(fn,n,interval){ return (...rest) => { let cnt = 0 let timer = null timer = setInterval(() => { fn.apply(fn,rest) cnt++ if(cnt >= n){ clearInterval(timer) timer = null } },interval) } } function log(){ console.log(this) } const repeatFunc = repeat(log, 4, 1000) repeatFunc()
以自己现在的努力程度,还没有资格和别人拼天赋