延时顺序打印

        const myPromise = num=>{
            return new Promise((resolve,reject)=>{
                setTimeout(()=>{
                    resolve(num)
                },1000)
            })
        }

        async function test(){
            for(let i = 0;i<5;){
                i++
                console.log(await myPromise(i));
            }
        }

        test()
虚心学习、丰富自己
原文地址:https://www.cnblogs.com/tkqq000/p/14868172.html