You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// 参数1:需要循环执行的函数数组; 参数2:执行的时间间隔constdoLoop=(fns,interval)=>{letstep=0constexcu=(fn)=>{if(typeoffn!=='function'){thrownewError(`'${fn}' is not a function`)}setTimeout(()=>{fn()++stepif(step>=fns.length){// 使用setTimeout避免栈溢出setTimeout(()=>{doLoop(fns,interval)},interval)}else{excu(fns[step])}},step===0 ? 0 : interval)}excu(fns[0])}// testconstA=()=>{console.log('A')}constB=()=>{console.log('B')}constC=()=>{console.log('C')}constD=()=>{console.log('D')}doLoop([A,B,C,D],500)
The text was updated successfully, but these errors were encountered:
The text was updated successfully, but these errors were encountered: