es9语法:for await of 的用法

 function getTime(seconds){
            return new Promise(resolve=>{
                setTimeout(() => {
                    resolve(seconds)
                }, seconds);
            })
        }

         

        async function test(){
            let arr = [getTime(2000),getTime(300),getTime(1000)]
            for await (let x of arr){
                console.log(x); // 2000  300 1000 按顺序的
            }
         }

        test()
原文地址:https://www.cnblogs.com/luguankun/p/13759498.html