JavaScript Function Queue

前端 未结 6 2030
小蘑菇
小蘑菇 2021-01-18 16:40

I have a ton of functions that need to run in succession, but not before the other has completed. What I need is a way to queue these functions to run only after the previou

6条回答
  •  花落未央
    2021-01-18 17:17

    To make sure they run consecutively, you might return a value from each one and use that returned value in the subsequent one...

    function do_1_to_5() {
    
        r1 = Function1(); 
        r2 = Function2(r1); 
        r3 = Function3(r2); 
        r4 = Function4(r3); 
        r5 = Function5(r4);
    
    }
    

提交回复
热议问题