写一个 mySetInterval(fn, a, b),每次间隔 a,a+b,a+2b 的时间,然后写一个 myClear,停止上面的 mySetInterval
function mySetInterval(fn,a,b,flag = 0){ setTimeout(() => { fn(a + b * flag) flag++ mySetInterval && mySetInterval(fn,a,b,flag) },a + b * flag) } function myClearInterval(){ window.mySetInterval && (window.mySetInterval = null) } function log(timeInterval){ console.log(timeInterval) }