async / await simple to use

async function process(array) {   for await (let i of array) {     setTimeout(function(){console.log(i);},i*1000);  } }
process([6,3,4,9,1])
//输出结果:
//        1
//        3
//        4
//        6
//        9

 

Guess you like

Origin www.cnblogs.com/shurun/p/11939880.html