8.7w+
社区成员
async function aaa(){
for (let val of [1, 2, 3, 4]) {
let t = await new Promise((resolve, reject)=>{
setTimeout(() => resolve(val), 100 * Math.random());
});
console.log(t);
}
}
async function aaa(){
for (let val of [1, 2, 3, 4]) {
await new Promise((resolve, reject)=>{
setTimeout(() =>{
console.log(val);
resolve();
}, 100 * Math.random());
});
}
}