js 异步循环嵌套

function recurTest(j, length){
    setTimeout(function(){
        console.log("第"+(j+1)+"次循环");
        if(++j < length){
            recurTest(j, length);
        }
    }, Math.random() * 3000);
}

function testPromise(){
    recurTest(0,10)
}

完美解决循环回调,有依赖关系的处理

发布了53 篇原创文章 · 获赞 2 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/frankxixu/article/details/98325803
今日推荐