function Gen(time) {
return new Promise((resolve, reject) => {
setTimeout(function () {
resolve(time)
},time)
})
}
async function test() {
let arr = [Gen(2000), Gen(200), Gen(3000)]
for(let i of arr) {
console.log(Date.now())
console.log(Date.now(), await i.then(console.log))
console.log(Date.now())
}
}
test().then(() => {console.log('<<<======华丽分割线======>>>'); testTwo()})
async function testTwo() {
let arr = [Gen(3000), Gen(300), Gen(2000)]
for await (let i of arr) {
console.log(Date.now(), i)
}
}
图片暂时无法加载