lets,n=0;functionmainLoop(){s=setTimeout(function(){doSomeThing();mainLoop();},1000);}functiondoSomeThing(){n++;console.log(n);if(n>5){stop();}}functionstop(){console.log("---stop----")clearTimeout(s);}mainLoop();上面这段代码为什么执行五次以后不会自动停止啊?
慕姐4208626
阿晨1998
相关分类